Swoole support for Mezzio

3.3.1 2021-05-26 21:19 UTC


Build Status Coverage Status

This library provides the support of Swoole into an Mezzio application. This means you can execute your Mezzio application using Swoole directly from the command line.


Run the following to install this library:

$ composer require mezzio/mezzio-swoole


After installing mezzio-swoole, you will need to first enable the component, and then optionally configure it.

We recommend adding a new configuration file to your autoload directory, config/autoload/swoole.local.php. To begin with, use the following contents:


use Mezzio\Swoole\ConfigProvider;

return array_merge((new ConfigProvider())(), []);

The above will setup the Swoole integration for your application.

By default, Swoole executes the HTTP server with host on port 8080. You can change these values via configuration. Assuming you have the above, modify it to read as follows:


use Mezzio\Swoole\ConfigProvider;

return array_merge((new ConfigProvider())(), [
    'mezzio-swoole' => [
        'swoole-http-server' => [
            'host' => 'insert hostname to use here',
            'port' => 80, // use an integer value here

Mezzio skeleton 3.1.0 and later

If you have built your application on the 3.1.0 or later version of the Mezzio skeleton, you do not need to instantiate and invoke the package's ConfigProvider, as the skeleton supports it out of the box.

You will only need to provide any additional configuration of the HTTP server.


Once you have performed the configuration steps as outlined above, you can run an Mezzio application with Swoole via the laminas-cli integration:

$ ./vendor/bin/laminas mezzio:swoole:start

Call the laminas command without arguments to get a list of available commands, looking for those that begin with mezzio:swoole:, and use the help meta-argument to get help on individual commands:

$ ./vendor/bin/laminas help mezzio:swoole:start


Browse the documentation online at