There is now an official Zend library for integrating swoole with zend expressive: https://github.com/zendframework/zend-expressive-swoole/
Swoole HTTP server integration with Zend Expressive framework
- PHP >= 7.1
- ext-swoole >= 2.0
- Zend Expressive v3 application
Support for older version v2 of Zend Expressive is provided in version 0.2 of this library.
This package is installable and autoloadable via Composer as samuelnogueira/zend-expressive-swoole.
composer require samuelnogueira/zend-expressive-swoole
<?php // config/autoload/swoole.global.php
return [
'swoole_http_server' => [
'host' => '127.0.0.1', // default is '0.0.0.0'
'port' => 80, // default is 8080
'settings' => [ // default is []. See see https://rawgit.com/tchiotludo/swoole-ide-helper/english/docs/classes/swoole_server.html#method_set
'http_parse_post' => false,
'worker_num' => 100,
],
'hot_code_reload' => [
'enabled' => true, // default is false
'interval' => 500, // default is 1000. Milliseconds between file changes checks.
],
],
];
Any omitted config key will fallback to the default value in the comments above.
# Start swoole HTTP booting your Zend Expressive app
$ ./vendor/bin/swoole
To enable hot code reload, add the following configuration:
<?php // config/autoload/swoole.global.php
return [
'swoole_http_server' => [
// (...)
'hot_code_reload' => [
'enabled' => true,
],
],
];
With this feature enabled, each swoole worker will keep track of included PHP files using inotify, and will restart all workers if a file is changed.
This serves to enable easier development when using swoole server.
Do not use this feature in production. It doesn't perform well for a big number of workers, nor is it safe.
-
Cookies retrievable via \Psr\Http\Message\ServerRequestInterface::getCookieParams -
Configurable number of workers -
Hot code reload -
Add support for Zend Expressive 3 - Include
Cookie
header in generated PSR-7 Server Request - Handle uploaded files
- Stream request body instead of buffering it
-
Stream response body instead of buffering it - Windows support?