2017 © Pedro Peláez
 

library zend-expressive-swoole

Swoole HTTP server integration with Zend Expressive framework

image

samuelnogueira/zend-expressive-swoole

Swoole HTTP server integration with Zend Expressive framework

  • Friday, June 8, 2018
  • by samuelnogueirajumia
  • Repository
  • 1 Watchers
  • 3 Stars
  • 870 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 71 % Grown

The README.md

This library is abandoned and no longer maintained

There is now an official Zend library for integrating swoole with zend expressive: https://github.com/zendframework/zend-expressive-swoole/, (*1)

Packagist Pre Release Scrutinizer Code Quality Code Coverage Build Status CircleCI Code Intelligence Status, (*2)

Swoole HTTP server integration with Zend Expressive framework, (*3)

Requirements

Support for older version v2 of Zend Expressive is provided in version 0.2 of this library., (*4)

Installation

This package is installable and autoloadable via Composer as samuelnogueira/zend-expressive-swoole., (*5)

composer require samuelnogueira/zend-expressive-swoole

Configuration

<?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., (*6)

Usage

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

Hot Code Reload

To enable hot code reload, add the following configuration:, (*7)

<?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., (*8)

This serves to enable easier development when using swoole server., (*9)

Do not use this feature in production. It doesn't perform well for a big number of workers, nor is it safe., (*10)

TODO

  • [x] ~~Cookies retrievable via \Psr\Http\Message\ServerRequestInterface::getCookieParams~~
  • [x] ~~Configurable number of workers~~
  • [x] ~~Hot code reload~~
  • [x] ~~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
  • [x] ~~Stream response body instead of buffering it~~
  • [ ] Windows support?

The Versions