[Bug] class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
See original GitHub issueBug report
What I did
I used an fluent syntax to create the field. The database is mongodb (jenssegers / laravel-mongodb)
eg CRUD::field('price')->type('number')
What I expected to happen
The backpack will display the fields as usual.
What happened
call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver' {"userId":1,"exception":"[object] (ErrorException(code: 0): call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\\Database' does not have a method 'getDoctrineDriver' at /mnt/c/laragon/www/protyre/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Connection.php:279)
What I’ve already tried to fix it
Everything works normally when it uses the old syntax
Backpack, Laravel, PHP, DB version
When I run php artisan backpack:version
the output is:
PHP VERSION:
PHP 7.4.5 (cli) (built: Apr 19 2020 07:36:30) ( NTS ) Copyright © The PHP Group Zend Engine v3.4.0, Copyright © Zend Technologies with Zend OPcache v7.4.5, Copyright ©, by Zend Technologies
LARAVEL VERSION:
v7.13.0@6fa69bfbd57744a5bbec5538ce483919b3fd625f
BACKPACK VERSION:
4.1.6@cbd4143d3eb8302916012af205565cd3183f274f
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Hi, thanks for the reply.
Yes, I saw that PR, after writing the answer above. I see you’re trying, it’s not easy, architecturally speaking.
I absolutely didn’t mean to say that you should put that code in the library, it was meant as a quick fix for people stumbling upon here 😃
I will give that PR a try, just give a couple of days 😃
Cheers Luca
Hello @MeerKatDev thanks for taking time to take a look at it.
This issue was from almost one year ago, and in the meantime we have trying to make Backpack the most compatible possible with other DB types other than SQL.
I’v also created a PR that allow MongoDB (and probably other No-SQL dbs) to work with BP. Check it here: https://github.com/Laravel-Backpack/CRUD/pull/3401
It have been postponed to 4.2 as we have bug squashing as a priority in 4.1. Some code of that PR had already changed while fixing bugs in 4.1, so it might need a little polishing.
I do agree with you that we should support, or atleast try, but as you can see, commenting out code that is there to make SQL work in favor of MongoDB is not the way to go.
Going back about the PR, I don’t think it’s a Breaking Change, so we might be able to merge it in 4.1, but our focus have been in other places. That said, if you give it a try let us know in the PR thread, it would help to speed up the merging process, now, or in 4.2 anyway.
Wish you the best, Pedro