我在workerman使用模型時會報錯,在webman中能正常使用
$tcp_worker->onMessage = function ($connection, $data) {
Department::get();//這里會報對象沒有初始化
$connection->send('Received: ' . $data);
};
請發(fā)原始的完整報錯
PS D:\php7\www\webman\process> php WorkermanTcpService.php start
---------------------------------------------- WORKERMAN -----------------------------------------------
Workerman version:4.1.15 PHP version:8.2.4
----------------------------------------------- WORKERS ------------------------------------------------
worker listen processes status
none tcp://0.0.0.0:2016 1 [ok]
Error: Call to a member function connection() on null in D:\php7\www\webman\vendor\illuminate\database\Eloquent\Model.php:1820
Stack trace:
PS D:\php7\www\webman\process>
應(yīng)該是沒初始化數(shù)據(jù)庫
https://github.com/illuminate/database
參考他們文檔初始化
在webman里會自動初始化