liufee / yii2-swoole

yii2 swoole,让yii2运行在swoole上
http://swoole.cms.qq.feehi.com
350 stars 76 forks source link

yii 新手,折腾了两小时了,求指点如何处理。 #23

Closed 13823761206 closed 4 years ago

13823761206 commented 5 years ago

Exception 'yii\base\UnknownPropertyException' with message 'Setting unknown property: yii\console\Application::swoole'

in /home/wwwroot/advanced/vendor/yiisoft/yii2/base/Component.php:209

Stack trace:

0 /home/wwwroot/advanced/vendor/yiisoft/yii2/BaseYii.php(546): yii\base\Component->__set('swoole', Array)

1 /home/wwwroot/advanced/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(yii\console\Application), Array)

2 /home/wwwroot/advanced/vendor/yiisoft/yii2/base/Application.php(206): yii\base\BaseObject->__construct(Array)

3 /home/wwwroot/advanced/vendor/yiisoft/yii2/console/Application.php(89): yii\base\Application->__construct(Array)

4 /home/wwwroot/advanced/yii(22): yii\console\Application->__construct(Array)

5 {main}

13823761206 commented 5 years ago

好冷清。

13823761206 commented 5 years ago

处理了,这样配置就ok了。 <?php $params = array_merge( require(__DIR__ . '/../../common/config/params.php'), require(__DIR__ . '/../../common/config/params-local.php'), require(__DIR__ . '/params.php'), require(__DIR__ . '/params-local.php') ); defined('SWOOLE_PROCESS') or define('SWOOLE_PROCESS', 1); defined('SWOOLE_TCP') or define('SWOOLE_TCP', 1); return [ 'id' => 'app-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'console\controllers', 'components' => [ 'log' => [ 'targets' => [ [ 'class' => yii\log\FileTarget::className(), 'levels' => ['error', 'warning'], ], ], ], 'session' => [ 'class' => yii\web\Session::className() ] ], 'controllerMap'=>[ 'serve' => [ 'class' => yii\console\controllers\ServeController::className(), 'docroot' => '@frontend/web', ], 'swoole' => [ 'class' => feehi\console\SwooleController::className(), 'rootDir' => str_replace('console/config', '', __DIR__ ),//yii2项目根路径 'type' => 'advanced',//yii2项目类型,默认为advanced。此处还可以为basic 'app' => 'frontend',//app目录地址,如果type为basic,这里一般为空 'host' => '127.0.0.1',//监听地址 'port' => 9999,//监听端口 'web' => 'web',//默认为web。rootDir app web目的是拼接yii2的根目录,如果你的应用为basic,那么app为空即可。 'debug' => true,//默认开启debug,上线应置为false 'env' => 'dev',//默认为dev,上线应置为prod 'swooleConfig' => [//标准的swoole配置项都可以再此加入 'reactor_num' => 2, 'worker_num' => 4, 'daemonize' => false, 'log_file' => __DIR__ . '/../../frontend/runtime/logs/swoole.log', 'log_level' => 0, 'pid_file' => __DIR__ . '/../../frontend/runtime/server.pid', ], ], 'swoole-backend' => [ 'class' => feehi\console\SwooleController::className(), 'rootDir' => str_replace('console/config', '', __DIR__ ),//yii2项目根路径 'app' => 'backend', 'host' => '127.0.0.1', 'port' => 9998, 'web' => 'web',//默认为web。rootDir app web目的是拼接yii2的根目录,如果你的应用为basic,那么app为空即可。 'debug' => true,//默认开启debug,上线应置为false 'env' => 'dev',//默认为dev,上线应置为prod 'swooleConfig' => [ 'reactor_num' => 2, 'worker_num' => 4, 'daemonize' => false, 'log_file' => __DIR__ . '/../../backend/runtime/logs/swoole.log', 'log_level' => 0, 'pid_file' => __DIR__ . '/../../backend/runtime/server.pid', ], ] ], 'params' => $params, ];