compwright / swoole-psr7-compat
PSR compatibility adapters for Swoole
Installs: 1 258
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- mezzio/mezzio-swoole: ^4.3
- nyholm/psr7-server: ^1.0
- psr/http-message: ^1.0
- psr/http-server-handler: ^1.0
Requires (Dev)
- laminas/laminas-diactoros: ^2.6
- nyholm/psr7: ^1.4
- phpunit/phpunit: ^9.4
- psalm/plugin-phpunit: ^0.17.0
- slim/psr7: ^1.4
- squizlabs/php_codesniffer: ^3.6
README
PSR compatibility adapters for Openswoole
Install
Via Composer
$ composer require compwright/swoole-psr7-compat
Usage
use Compwright\SwoolePsr7Compat\SwoolePsrRequestFactory; use Compwright\SwoolePsr7Compat\SwoolePsrHandler; use Nyholm\Psr7Server\ServerRequestCreator; $serverRequestCreator = new ServerRequestCreator( // Pass in the factories here for your desired PSR-7 implementation new \Laminas\Diactoros\ServerRequestFactory(), new \Laminas\Diactoros\UriFactory(), new \Laminas\Diactoros\UploadedFileFactory(), new \Laminas\Diactoros\StreamFactory() ); $requestFactory = new SwoolePsrRequestFactory($serverRequestCreator); $handler = new SwoolePsrHandler($requestFactory); $server = new Swoole\HTTP\Server('0.0.0.0', 9501); // $app is any Psr\Http\Server\RequestHandlerInterface $server->on('request', $handler($app)); $server->start();