# yii2-swoole-demo **Repository Path**: deepziyu/yii2-swoole-demo ## Basic Information - **Project Name**: yii2-swoole-demo - **Description**: yii2-swoole 协程异步示例,API编写。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 0 - **Created**: 2017-09-05 - **Last Updated**: 2022-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # yii2-swoole-demo _为赋予 Yii2 框架协程异步能力而生。_ 使用 [yii2-swoole](https://github.com/deepziyu/yii2-swoole) 来搭建api接口的一个简单示例。 ## 安装 #### 环境要求 1. hiredis 2. composer 3. PHP7.X 4. Swoole2.0.9 且开启协程和异步 redis #### swoole install - 参考 https://wiki.swoole.com/wiki/page/p-coroutine.html - 参考 https://wiki.swoole.com/wiki/page/589.html #### composer update - 执行 `$ php composer.phar update` 或 `$ composer update` 进行安装。 ## 配置 新建你的本地配置文件 api/config/main-local.php . 比如: ```php return [ 'components' => [ 'request' => [ 'cookieValidationKey' => 'FdPAJxP6LVN00MpdiMBxUef1i-H0mG7v', ], 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=127.0.0.1;port=3306;dbname=homestead;charset=utf8', 'username' => 'homestead', 'password' => 'secret', 'attributes' => [ ], ], ], ]; ``` ## 启动 ``` php api/bin/swoole.php start|stop|reload|reload-task ``` ## 访问 127.0.0.1:9501 ## 链接 [gitee 仓库](https://gitee.com/lizhenju/yii2-swoole) [gihub 仓库](https://github.com/deepziyu/yii2-swoole)