parker714/yii2-s

使用swoole加速yii2应用

安装: 164

依赖: 0

建议者: 0

安全: 0

星标: 34

关注者: 6

分支: 3

开放问题: 0

类型:yii2-extension

3.0.3 2019-11-12 11:07 UTC

This package is auto-updated.

Last update: 2024-09-12 21:40:43 UTC


README

为Yii 2提供的Swoole扩展

本扩展为基于Yii框架2.0swoole的swoole扩展。

关于许可证信息,请查看LICENSE文件。

Latest Stable Version

安装

安装此扩展的首选方式是通过composer

运行以下命令

composer require parker714/yii2-s -vvv

使用方法

安装后,您需要修改配置,然后使用它

# 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

教程

1.更多使用方法

2.在yii2中使用swoole的思路

添加微信了解更多信息

Usage example of Yii2 shell