Db::connection('mongodb')->collection('test')->insert([1,2,3]);
return json(Db::connection('mongodb')->collection('test')->get());
Error: Class "Jenssegers\Mongodb\Connection" not found in /www/wwwroot/demo/vendor/workerman/webman-framework/src/support/bootstrap/LaravelDb.php:58
php => 8.2
mongoDB extension version => 1.16.2
相关依赖包的版本如下:
"workerman/webman-framework": "^1.5.0",
"illuminate/database": "^10.29",
"jenssegers/mongodb": "^4.0.0"
如何修复?请大佬们不吝赐教
按照手册安装 3.8版本
composer require -W illuminate/database jenssegers/mongodb ^3.8.0
或者升级下
composer require workerman/webman-framework ^v1.5.11
谢谢大佬!升级workerman/webman-framework ^v1.5.11版本已解决。
第一种方法,按照手册安装jenssegers/mongodb ^3.8.0,因为依赖包illuminate/database的版本冲突无法完成安装所以才选择安装jenssegers/mongodb ^4.0.0的