引入文件:
use \GatewayWorker\Lib\Gateway;
use \GatewayWorker\Lib\Db;
public static $mysql = null;
public static function onWorkerStart($worker)
{
self::$mysql = new Workerman\MySQL\Connection('127.0.0.1', '3306', 'root', 'root', 'workerman');
}
出错一直出现:
PHP Fatal error: Class 'Workerman\MySQL\Connection' not found in E:\work\GatewayWorker\Applications\YourApp\Events.php on line 45
http://doc3.workerman.net/component/workerman-mysql.html
先安装
我的GatewayWorker版本3.0.7,在Events.php 里面,onWorkerStart()方法里,可以直接 通过
self::$db = new \GatewayWorker\Lib\DbConnection('127.0.0.1', '3306', 'xxx', 'xxx', 'xxx');访问MySQL,并没有先通过composer 安装 workman/MySQL 组件,不知道原因
我也遇到了同样的问题,请问要怎么解决呀?????、
要先安装 pdo和pdo_mysql 这两个扩展