insidestyles / swoole-bridge
Swoole Bridge For Php Frameworks
v1.0.1
2023-02-05 14:44 UTC
Requires
- php: >=7.1
- ext-swoole: >=2.1.0
- psr/http-message: ^1.0
- psr/http-server-handler: ^1.0
- psr/log: ^1.0
Requires (Dev)
- eaglewu/swoole-ide-helper: dev-master
- illuminate/contracts: >=8.0
- laminas/laminas-diactoros: ^2.0
- phpunit/phpunit: >=6.5
- symfony/http-kernel: ^5.0|^6.0
- symfony/psr-http-message-bridge: ^1.0|^2.0
Suggests
- symfony/http-kernel: Allows adapter for symfony
- symfony/psr-http-message-bridge: Allows builder for Symfony http message
- zendframework/zend-expressive: Allows adapter for Zend Expressive
This package is auto-updated.
Last update: 2024-11-05 19:02:20 UTC
README
Swoole Bridge For Php Frameworks. Currently supports:
- Symfony
- Zend Expressive
- Laravel
Requirements
- PHP >= 7.1
- ext-swoole >= 2.1
Installation
This package is installable and autoloadable via Composer
composer require insidestyles/swoole-bridge
Usage
example:
<?php $kernel = new Kernel($env, $debug);//App\Kernel or AppKernel; $psr15Kernel = new \Insidestyles\SwooleBridge\Adapter\Kernel\Psr15SymfonyKernel($kernel); //Laravel: $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); //$psr15Kernel = new \Insidestyles\SwooleBridge\Adapter\Kernel\Psr15IlluminateKernel($kernel); //Zend Expressive: $psr15Kernel = $container->get(\Zend\Expressive\Application::class); $host = '127.0.0.1'; $port = 8080; $http = new \swoole_http_server($host, $port); $responseEmitter = new \Insidestyles\SwooleBridge\Emiter\SwooleResponseEmitter(); $requestBuilderFactory = new \Insidestyles\SwooleBridge\Builder\RequestBuilderFactory(); $factory = new \Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory(); $adapter = new \Insidestyles\SwooleBridge\Adapter\SymfonyAdapter($responseEmitter, $psr15Kernel, $requestBuilderFactory); $logger = new \Psr\Log\NullLogger(); $handler = new \Insidestyles\SwooleBridge\Handler($adapter, $logger); $http->on( 'request', function (\Swoole\Http\Request $request, \Swoole\Http\Response $response) use ($handler) { $handler->handle($request, $response); } ); $http->start();
TODO
- Laravel support?
- Yii support?