I have a Laravel 5.1 application running on Ubuntu 16.04 and PHP 5.6
This was previously using mongo.so (the older MongoDB PHP driver) and I have migrated it to the new driver mongodb.so - this was required since I upgraded MongoDB to 3.4 and would like to connect to a MongoDB Replica Set
I was using Jennseger's library to connect, which I also upgraded - and updated the to the laravelcollective/html library as well
The current composer.json file looks like this:
..
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"laravelcollective/html": "5.1.*",
"jenssegers/mongodb": "3.0.*",
..
When I login to the application, it generates the following error:
in Builder.php line 214
at HandleExceptions->handleError('4096', 'Argument 2 passed to Illuminate\Database\Query\Builder::__construct()
must be an instance of Illuminate\Database\Query\Grammars\Grammar, null given, called in
<app_root>/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 1873 and defined',
'<app_root>/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php', '214', array('connection' => object(Connection))) in Builder.php line 214
I have followed the guidelines to a similar error and replaced my Eloquent models
e.g. the following:
use Jenssegers\Mongodb\Model;
class Alert extends Model
{
..
..
}
is replaced by:
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class Alert extends Eloquent {
..
..
}
and the User model is now:
use App\Scopes\Traits\ReportingTrait;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Bican\Roles\Traits\HasRoleAndPermission;
use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent implements AuthenticatableContract, CanResetPasswordContract, HasRoleAndPermissionContract
{
use Authenticatable, CanResetPassword, HasRoleAndPermission, ReportingTrait;
..
..
}
There is a readme from a previous version for the jennsegers library here
I seem to have the requirements checked - including:
> php -i | grep 'Mongo'
MongoDB support => enabled
MongoDB extension version => 1.2.9
MongoDB extension stability => stable
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire