question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] class 'MongoDB\Database' does not have a method 'getDoctrineDriver'

See original GitHub issue

Bug 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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
MeerKatDevcommented, Mar 15, 2021

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

0reactions
pxpmcommented, Mar 15, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

class 'MongoDB\Database' does not have a method ... - GitHub
When I run: php artisan ide-helper:models I get this error on all my models: Exception: call_user_func_array() expects parameter 1 to be a ...
Read more >
Problems with jenssegers Laravel MongoDB Eloquent
I'm starting to use jenssegers/laravel-mongodb library to handle my mongodb database, I was trying it out, doing some examples by my self and...
Read more >
Laravel-MongoDB "Class db does not exist" error
Are you using db instead of DB in code? Use the uppercase DB . Also, check to see if you need to use...
Read more >
laravel-mongodb - Bountysource
I have a hybrid setup with MySQL and MongoDB. Eager Loading latest item of relation is not working correctly. I want to load...
Read more >
db.collection.insert() — MongoDB Manual
The following examples insert documents into the products collection. If the collection does not exist, the insert() method creates the collection. Insert a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found