razonyang/yii-runner-swoole

Yii web application runner for Swoole

dev-main 2022-09-17 08:09 UTC

This package is auto-updated.

Last update: 2024-11-17 13:09:27 UTC


README

Latest Stable Version Total Downloads Build Status Coverage Status

The Swoole adapter for Yii Runner, built on top of Swoole coroutine.

Installation

composer require razonyang/yii-runner-swoole --prefer-dist

Entrypoint

<?php
// server.php
declare(strict_types=1);

use RazonYang\Yii\Runner\Swoole\SwooleApplicationRunner;

ini_set('display_errors', 'stderr');

require_once __DIR__ . '/autoload.php';

(new SwooleApplicationRunner(__DIR__, $_ENV['YII_DEBUG'], $_ENV['YII_ENV']))->run();

Start the server.

php server.php

Configuration

<?php

declare(strict_types=1);

return [
    'razonyang/yii-runner-swoole' => [
        'pool' => [
            'workerNumber' => 4,
        ],
        'server' => [
            'host' => '0.0.0.0',
            'port' => 9501,
        ],
        'coroutine' => [
            'options' => [
                // See https://wiki.swoole.com/#/coroutine/coroutine?id=set.
                // 'log_level' => SWOOLE_LOG_TRACE,
                // 'trace_flags' => SWOOLE_TRACE_ALL,
            ],
        ],
    ],
];