Open bubooon opened 5 years ago
What is your PHP version and SWOOLE version
What is your PHP version and SWOOLE version
PHP 7.3 Swoole 4.3.4
i try Swoole 4.3.4 and it's ok, please check yii2 db config,whether as same as
$server = array(
'host' => 'mysql',
'port' => 3306,
'user' => 'root',
'password' => 'pw',
'database' => 'dbname',
);
i try Swoole 4.3.4 and it's ok, please check yii2 db config,whether as same as
$server = array( 'host' => 'mysql', 'port' => 3306, 'user' => 'root', 'password' => 'pw', 'database' => 'dbname', );
Be sure, I checked it many times(
i saw mysql host name is 'mysql', can retry instead of ip. BTW, what's your method to do injection in native YII2.
i saw mysql host name is 'mysql', can retry instead of ip. BTW, what's your method to do injection in native YII2.
My host is "mysql" because my project inside docker and mysql is another service from docker-compose.
In my Yii2 project without swoole I added after included Yii.php:
require(__DIR__ . '/components/dependency/gsDependencies.php');
This file contains code like this:
Yii::$container->set('yii\web\User', 'gscomponents\gsWebUser');
Yii::$classMap['yii\web\View'] = __DIR__.'/gsView.php';
And now with swoole i can't rewrite behaviour of default User class or View etc.
add to swoole server start script like
Server::run($config, function (Server $server) {
$starter = new \tsingsun\swoole\bootstrap\WebApp($server);
$starter->init = function (\tsingsun\swoole\bootstrap\BaseBootstrap $bootstrap) {
require(__DIR__ . '/yii2-app-basic/vendor/tsingsun/yii2-swoole/src/Yii.php');
//additional script
require(__DIR__ . '/components/dependency/gsDependencies.php');
Yii::setAlias('@webroot', WEBROOT);
Yii::setAlias('@web', '/');
Yii::$swooleServer = $bootstrap->getServer()->getSwoole();
$bootstrap->appConfig = $config;
};
}
Hi, I have two questions. 1) I trying to add yii2-swoole to my yii2 project. But I saw that you hide Yii::$container interface, and now I can't do injection before app will run, how i can do it? 2) When i did request for app, i got an error that a MySql connection is not established. Logs below:
I can't understand why, because simple example like this works fine: