不支持的驱动程序[mongodb] laravel 5.4.36

I try to connect the Laravel 5.4.36 with mongodb

My mongo db version v3.4.16 installed

composer require jenssegers/mongodb:3.2.0
jenssegers/mongodb-session
jenssegers/mongodb-sentry

config/app.php

Jenssegers\Mongodb\MongodbServiceProvider::class,

Mymodel

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class Mymodel extends Eloquent
{
    protected $connection = 'mongodb';
    protected $collection = 'addresses';
}

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Mymodel;
use Illuminate\Support\Facades\DB;

class ConnectmongoController extends Controller
{
    public function index()
    {
        $node = Mymodel::all();
        echo "hi";
    }
}

config/database.php

'mongodb' => [
                'driver'   => 'mongodb',
                'host'     => 'localhost',
                'port'     =>  27017,
                'database' => 'mydb',
                'username' => 'usrename',
                'password' => 'password',
                'options'  => [
                    'database' => 'admin' // sets the authentication database required by mongo 3
                ]
],

phpinfo

enter image description here

While i call the controller function it shows the error

1/1) InvalidArgumentException Unsupported driver [mongodb]

in ConnectionFactory.php line 286

I am not able to find where i did mistake/Miss any steps.

1个回答



MongoDB Extension ^ 1.5不支持mongoDB 2.6 </ p>

https://docs.mongodb.com/ecosystem/drivers/php/#mongodb-compatibility < / p>
</ div>

展开原文

原文

MongoDB Extension ^1.5 does not support mongoDB 2.6

https://docs.mongodb.com/ecosystem/drivers/php/#mongodb-compatibility

dongzhi6087
dongzhi6087 解决了错误。 现在它说认证失败了。 我提供正确的用户用户名和密码。 我不知道为什么我得到错误
大约 2 年之前 回复
douliu1092
douliu1092 更新了我的mongodb版本到3.4.16仍然我得到了相同的错误不支持的驱动程序[mongodb]
大约 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐