在使用webman查询数据表所有数据时报错,第一次用这个框架,实在没找到解决办法,希望各位大佬能帮帮忙
访问 http://127.0.0.1:8787/api/getNews 就会出现下面的报错
控制器文件
<?php
namespace app\controller;
use support\Request;
use support\Db;
class ApiController
{
public function getNews(Request $request)
{
return Db::table('api_news')->get();
}
}
Error: Class 'Illuminate\Database\Capsule\Manager' not found in E:\desktop\project\sharkcms\webman\vendor\workerman\webman-framework\src\support\Db.php:33
Stack trace:
#0 E:\desktop\project\sharkcms\webman\vendor\composer\ClassLoader.php(571): include()
#1 E:\desktop\project\sharkcms\webman\vendor\composer\ClassLoader.php(428): Composer\Autoload\includeFile('E:\\desktop\\proj...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('support\\Db')
#3 E:\desktop\project\sharkcms\webman\app\controller\ApiController.php(12): spl_autoload_call('support\\Db')
#4 E:\desktop\project\sharkcms\webman\vendor\workerman\webman-framework\src\App.php(319): app\controller\ApiController->getNews(Object(support\Request))
#5 E:\desktop\project\sharkcms\webman\vendor\workerman\webman-framework\src\App.php(141): Webman\App::Webman\{closure}(Object(support\Request))
#6 E:\desktop\project\sharkcms\webman\vendor\workerman\workerman\Connection\TcpConnection.php(646): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#7 E:\desktop\project\sharkcms\webman\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #124)
#8 E:\desktop\project\sharkcms\webman\vendor\workerman\workerman\Worker.php(1479): Workerman\Events\Select->loop()
#9 E:\desktop\project\sharkcms\webman\vendor\workerman\workerman\Worker.php(1399): Workerman\Worker::forkWorkersForWindows()
#10 E:\desktop\project\sharkcms\webman\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#11 E:\desktop\project\sharkcms\webman\vendor\workerman\webman-framework\src\support\App.php(131): Workerman\Worker::runAll()
#12 E:\desktop\project\sharkcms\webman\start.php(4): support\App::run()
#13 {main}
数据库截图
数据库配置截图
windows11
Workerman version:4.1.10 PHP version:7.4.3
好了,解决了
怎么解决的呀
这个数据库操作组件需要额外安装,框架本身没有带,https://www.workerman.net/doc/webman/db/tutorial.html