Laravel-mongodb: Laravel 5.3: Call to a member function supportsSchemaTransactions() on null

Created on 22 Oct 2016  路  12Comments  路  Source: jenssegers/laravel-mongodb

Hi there,

I've just upgraded to Laravel 5.3 and also upgraded laravel-mongodb to 3.1.1.
Now when I'm trying to migrate the following error occurred:

PHP Fatal error:  Call to a member function supportsSchemaTransactions() on null in /private/var/www/laravel/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 378

I've set protected $connection = 'mongodb'; in my migration class.

BTW: up() method never fired, the error occurred before it I think.

Most helpful comment

@ahmadazimi Below is the fix to your issue:

Go to Connection.php which can be found in the Mongodb folder of this package and add these changes:

1) Add use Jenssegers\Mongodb\Schema\Grammar; right below the use MongoDB\Client;.

2) Inside the public function __construct(array $config) function, add $this->schemaGrammar = new Grammar();. It can come before any other code in the function.

Now head over to the Schema folder and create a new file called Grammar.php. The file should contain this:

<?php
namespace Jenssegers\Mongodb\Schema;

use Illuminate\Database\Schema\Grammars\Grammar as BaseGrammar;
/**
 * Class Grammar
 *
 * @package Moloquent\Schema
 */
class Grammar extends BaseGrammar
{
}

I found this fix in the moloquent fork of this package (https://github.com/moloquent/moloquent). Hope this helps you.

All 12 comments

I've just open commented on Laravel issue [https://github.com/laravel/framework/issues/15892#issuecomment-255517921]
They said the similar problem was fixed before but work in my case!

laravel version: 5.3.19
jenssegers/laravel-mongodb version: 3.1.1

+1. Rolled back to Laravel v5.3.18, which works.

@ellej16 make a comment on that Laravel issue:

As far as I checked jensessegers/laravel-mongodb's source code, it's missing a few key methods/attributes introduced by this particular PR: #15780 . If I remember correctly, one of those are: getSchemaGrammar() and useDefaultSchemaGrammar() on Connection.php (With this being the culprit behind your troubles).

Is there any chance to fix it here?

@ahmadazimi Below is the fix to your issue:

Go to Connection.php which can be found in the Mongodb folder of this package and add these changes:

1) Add use Jenssegers\Mongodb\Schema\Grammar; right below the use MongoDB\Client;.

2) Inside the public function __construct(array $config) function, add $this->schemaGrammar = new Grammar();. It can come before any other code in the function.

Now head over to the Schema folder and create a new file called Grammar.php. The file should contain this:

<?php
namespace Jenssegers\Mongodb\Schema;

use Illuminate\Database\Schema\Grammars\Grammar as BaseGrammar;
/**
 * Class Grammar
 *
 * @package Moloquent\Schema
 */
class Grammar extends BaseGrammar
{
}

I found this fix in the moloquent fork of this package (https://github.com/moloquent/moloquent). Hope this helps you.

Thank you @kofispaceman
I think I should switch to https://github.com/moloquent/moloquent ;-)

Was this fixed in the last Laravel release, or still an issue?

@jenssegers using Laravel v5.3.21 and jenssegers/mongodb v3.1.1

and still this is an issue!

Can you try the master branch?

@jenssegers Looks like it has been fixed in the master branch. Thanks!

@jenssegers Looks like it has been fixed in the master branch.

Thanks.

@jenssegers when we can have it in stable channel?

Will do this now

Was this page helpful?
0 / 5 - 0 ratings