5

I'm trying to use the debugbar with lumen and jenssegers/laravel-mongodb , it wasn't showing the database queries so I enabled.

\DB::connection('mongodb')->enableQueryLog();

But now it shows this error.

`Call to a member function listen() on null

in LaravelDebugbar.php line 354`

Another thing is that it only displays the debugbar on the home URL /, other than home URL it doesn't display the debugbar.

image

Without \DB::connection('mongodb')->enableQueryLog(); or \DB::enableQueryLog(); it renders, but doesn't show the database queries information, and it works with home page only.

image

Thank you

MZH
  • 1,414
  • 4
  • 29
  • 57
  • Have you made sure your mongo db is actually functioning without debugbar... Because the error you are getting is because the application's service container's binding for 'db' is null... – Kurt Friars Aug 13 '20 at 09:13
  • @KurtFriars yes that is working fine, without the laravel debugbar, it only raise the error when I enable Without \DB::connection('mongodb')->enableQueryLog(); or \DB::enableQueryLog(); in the bootstrap/app.php – MZH Aug 13 '20 at 09:17
  • If you look [here](https://github.com/barryvdh/laravel-debugbar/blob/0a09f4cb8879e4e31394553b953410cd941fcda7/src/LaravelDebugbar.php#L287), you will see it is trying to resolve db out of the container, and that is what ```listen``` is being called on. So I dont know why debugbar wont resolve it, but your app will... – Kurt Friars Aug 13 '20 at 09:19

1 Answers1

1

Where are you put \DB::connection('mongodb')->enableQueryLog();?

According to this issue on a master debugbar you need to call it on AppServiceProvider.php's boot() function. Did you try that?

If this above not working, rather search help on debugbar issues, because I think that problem is with the plugin, not your code. And there is a many Mongo issues, definitely look there first.

maki10
  • 553
  • 2
  • 11