laravel-debugbar
laravel-debugbar copied to clipboard
Queries in providers
Hi! The package doesn't show sql queries which are run from providers. Sometimes it's inconvenience. Is it possible to fix this?
Change providers priority order
What do you mean? Actually, I didn't add any debugbar provider. It just works.
I didn't add any debugbar provider. It just works.
that is due to laravel autodiscover
I understand, but it's set up out of the box
I have done:
- added the package in composer.json "dont-discover": ["barryvdh/laravel-debugbar"] and compoer update
- Added Barryvdh\Debugbar\ServiceProvider::class, in the config/app.php, the first in the list
- Added a test in the AppServiceProvider.php, boot() function: DB::table('user')->where('id', 1)->first();
But I still don't see this sql-request in the Queries tab of DebugBar =(
Where am I in the wrong?
Dont add it to config/app.php, try adding this on AppServiceProvider boot first line
if(class_exists(\Barryvdh\Debugbar\ServiceProvider::class)){
$this->app->register(new \Barryvdh\Debugbar\ServiceProvider($this->app));
}
Dont add it to config/app.php, try adding this on AppServiceProvider boot first line
if(class_exists(\Barryvdh\Debugbar\ServiceProvider::class)){ $this->app->register(new \Barryvdh\Debugbar\ServiceProvider($this->app)); }
Unfortunately, it doesn't help =( I tried this code:
public function boot(): void
{
if (class_exists(\Barryvdh\Debugbar\ServiceProvider::class)) {
$this->app->register(new \Barryvdh\Debugbar\ServiceProvider($this->app));
}
DB::table('user')->where('id', 1)->first();
}
and I tried DB::table('user')->where('id', 1)->first(); in another service provider down the queue. It doesn't work, 0 queries
no solution for this yet? having the same issue :(
It doesn't seem like a bug
Added a test in the AppServiceProvider.php, boot() function: DB::table('user')->where('id', 1)->first(); But I still don't see this sql-request in the Queries tab of DebugBar =( Where am I in the wrong?
ServiceProvider::boot
is executed before LaravelDebugbar::boot
, so debugbar isn't collecting data, therefore those sqls will not be in debugbar
You could force the debugbar boot in AppServiceProvider::boot
$this->app->make(\Barryvdh\Debugbar\LaravelDebugbar::class)->boot();
// After this line debugbar starts collecting
DB::table('user')->where('id', 1)->first();
But I don't know what disadvantages it would bring, maybe some collector does not register correctly, you would have to test it
It doesn't seem like a bug
Added a test in the AppServiceProvider.php, boot() function: DB::table('user')->where('id', 1)->first(); But I still don't see this sql-request in the Queries tab of DebugBar =( Where am I in the wrong?
ServiceProvider::boot
is executed beforeLaravelDebugbar::boot
, so debugbar isn't collecting data, therefore those sqls will not be in debugbarYou could force the debugbar boot in
AppServiceProvider::boot
$this->app->make(\Barryvdh\Debugbar\LaravelDebugbar::class)->boot(); // After this line debugbar starts collecting DB::table('user')->where('id', 1)->first();
But I don't know what disadvantages it would bring, maybe some collector does not register correctly, you would have to test it
Thanks, this is true, this is not a bug since in my case all queries are being executed at the app's boot time prior to Debugbar booting, and this solution helps a lot, thanks! My case was collecting data for ViewSeriveProvider.
There is still no config option to setup the priority without modifying AppServiceProvider
?