parker714/yii2-s

speed up yii2 app by swoole

Installs: 164

Dependents: 0

Suggesters: 0

Security: 0

Stars: 34

Watchers: 6

Forks: 3

Open Issues: 0

Type:yii2-extension

3.0.3 2019-11-12 11:07 UTC

This package is auto-updated.

Last update: 2024-10-12 21:52:44 UTC


README

Swoole Extension for Yii 2

This extension provides an swoole for Yii framework 2.0 based on swoole.

For license information check the LICENSE-file.

Latest Stable Version

Installation

The preferred way to install this extension is through composer.

Either run

composer require parker714/yii2-s -vvv

Usage

After installation, you need to modify the configuration and then use it:

# 1.Add the configuration in the console.php
...
'bootstrap'     => ['log'],
'controllerMap' => [
    'sw-http' => [
        'class'  => \parker714\yii2s\SwController::class,
        'server' => [
            'class'      => \parker714\yii2s\servers\Http::class,
            'webAppConf' => require(__DIR__ . '/web.php'),
    ],
...  

# 2.Put the web.php configuration,sw exception、request、response are different from php-fpm
...
'components' => [
    'errorHandler' => [
        'class'            => \parker714\yii2s\components\ErrorHandle::class,
        'as errorResponse' => [
            'class'    => \parker714\yii2s\behaviors\ErrorResponse::class,
        ],
    ],
    'response'     => [
        'class'  => \parker714\yii2s\components\Response::class,
        'format' => \yii\web\Response::FORMAT_JSON,
    ],
    'request'      => [
        'class'   => \parker714\yii2s\components\Request::class,
        'parsers' => [
            'application/json' => \yii\web\JsonParser::class,
        ],
    ]
...

# 3.Management server
./yii sw-http/server start|stop|reload

Tutorials

1.More ways to use

2.The idea of using swoole in yii2

Add WeChat to learn more

Usage example of Yii2 shell