samuelnogueira/zend-expressive-swoole

此包已被废弃,不再维护。作者建议使用 zendframework/zend-expressive-swoole 包。

Swoole HTTP服务器与Zend Expressive框架的集成

0.3.3 2018-06-06 16:11 UTC

This package is auto-updated.

Last update: 2022-02-01 13:11:56 UTC


README

现在有一个官方的Zend库,用于将swoole与zend expressive集成:https://github.com/zendframework/zend-expressive-swoole/

Packagist Pre Release Scrutinizer Code Quality Code Coverage Build Status CircleCI Code Intelligence Status

Swoole HTTP服务器与Zend Expressive框架集成

需求

此库的版本0.2提供了对较旧版本v2的Zend Expressive的支持。

安装

此包可以通过Composer安装和自动加载,作为 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.
        ],
    ],
];

省略的任何配置键将回退到上面注释中的默认值。

使用方法

# Start swoole HTTP booting your Zend Expressive app
$ ./vendor/bin/swoole

热代码重载

要启用热代码重载,请添加以下配置

<?php // config/autoload/swoole.global.php

return [
    'swoole_http_server' => [
        // (...)
        'hot_code_reload' => [
            'enabled'  => true,
        ],
    ],
];

启用此功能后,每个swoole工作进程将使用 inotify 跟踪包含的PHP文件,如果文件发生更改,则重启所有工作进程。

这有助于在使用swoole服务器时更容易地进行开发。

在生产环境中不要使用此功能。它对于大量工作进程的性能不佳,并且不安全。

待办事项

  • 通过 \Psr\Http\Message\ServerRequestInterface::getCookieParams 可检索的Cookies
  • 可配置的工作进程数量
  • 热代码重载
  • 添加对Zend Expressive 3的支持
  • 在生成的PSR-7 Server Request中包含Cookie
  • 处理上传文件
  • 流请求体而不是缓冲它
  • 流响应体而不是缓冲它
  • Windows支持?