按照文档上一步步走下来的,但是好像数据库连接失败了
查询代码
$name = Db::table('tb_park')->where('id', 1)->value('name');
return response("hello $name");
数据库配置文件
// 默认数据库
'default' => 'mysql',
'mysql' => [
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => 3306,
'database' => 'test_park',
'username' => 'root',
'password' => '123456',
'unix_socket' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
Error: Call to a member function connection() on null in E:\MXJK_GitLab\webman\vendor\illuminate\database\Capsule\Manager.php:87
Stack trace:
#0 E:\MXJK_GitLab\webman\app\api\controller\IndexController.php(19): Illuminate\Database\Capsule\Manager::table('tb_park')
#1 E:\MXJK_GitLab\webman\vendor\workerman\webman-framework\src\App.php(293): app\api\controller\IndexController->index(Object(support\Request))
#2 E:\MXJK_GitLab\webman\vendor\workerman\webman-framework\src\App.php(147): Webman\App::Webman\{closure}(Object(support\Request))
#3 E:\MXJK_GitLab\webman\vendor\workerman\workerman\Connection\TcpConnection.php(638): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#4 E:\MXJK_GitLab\webman\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #123)
#5 E:\MXJK_GitLab\webman\vendor\workerman\workerman\Worker.php(2467): Workerman\Events\Select->loop()
#6 E:\MXJK_GitLab\webman\vendor\workerman\workerman\Worker.php(1453): Workerman\Worker->run()
#7 E:\MXJK_GitLab\webman\vendor\workerman\workerman\Worker.php(1396): Workerman\Worker::forkWorkersForWindows()
#8 E:\MXJK_GitLab\webman\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#9 E:\MXJK_GitLab\webman\vendor\workerman\webman-framework\src\support\App.php(124): Workerman\Worker::runAll()
#10 E:\MXJK_GitLab\webman\start.php(4): support\App::run()
#11 {main}
数据库信息
这里写系统环境相关信息
win10 mysql5.7 php7.3
"workerman/webman-framework": "^1.4.3",
"monolog/monolog": "^2.0",
"psr/container": "1.1.1",
"illuminate/redis": "^8.83",
"illuminate/events": "^8.83",
"phpoffice/phpspreadsheet": "^1.25",
"illuminate/database": "^8.83",
"illuminate/pagination": "^8.83",
"symfony/var-dumper": "^5.4"
哇~感谢!!!我复制漏了~尴尬
哈哈哈