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

时间:2018-07-27 12:50:37

标签: php mongodb laravel-5

我尝试将Laravel 5.4.36与mongodb连接

我的mongo数据库版本v3.4.16 已安装

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

config / app.php

Jenssegers\Mongodb\MongodbServiceProvider::class,

我的模型

<?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';
}

控制器

<?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

虽然我调用控制器功能 它显示错误

  

1/1)InvalidArgumentException   不支持的驱动程序[mongodb]

     

在ConnectionFactory.php第286行中

我找不到我在哪里犯错了/没有任何步骤。

1 个答案:

答案 0 :(得分:0)