vendredi 27 juillet 2018

Unsupported driver [mongodb] laravel 5.4.36

I try to connect the laravel 5.4.36 with mongodb My mongo db version v2.6.10 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
                ]
],

My 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. If anybody found any error . Guide me in correct direction.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire