dangelsaurus
dangelsaurus

Reputation: 7532

Laravel Debugbar messages not showing

L5.0

I have the DebugBar installed, and it's working and showing at the bottom of the screen. But I'm having trouble figuring out how to send messages to the console to show up under "Messages"

I've tried the following in my controllers...

use DebugBar\DebugBar;
....
DebugBar::addMessage('This is a message');

or even

use DebugBar\DebugBar;
....
DebugBar::info('this is info');

but I'm getting the following error.

Call to undefined method DebugBar\DebugBar::info()

my app.php has the following.

'providers' => [
.....
'Barryvdh\Debugbar\ServiceProvider',
....


'aliases' => [ 
....
'DebugBar'  => 'Barryvdh\Debugbar\Facade',

I'm still a Laravel newbie, so not sure where to check next. I've checked the documentation on both http://phpdebugbar.com/docs/ and https://github.com/barryvdh/laravel-debugbar but I think I'm just missing something.

Upvotes: 4

Views: 13190

Answers (5)

Dawid Makowski
Dawid Makowski

Reputation: 1

Inside .env :

DEBUGBAR_ENABLED=true

Upvotes: 0

hegez
hegez

Reputation: 1028

For me, auto-injecting DebugBar\DebugBar as suggested by my IDE did not automatically work, but gave this error. Changing it to Barryvdh\Debugbar\Facade as DebugBar solved the problem. Seems that there is a totally different package named "DebugBar" installed in the default Laravel configuration.

So, if in the beginning of file you see:

use DebugBar\DebugBar;

Change it to:

use Barryvdh\Debugbar\Facade as DebugBar;

Also, if registered as a facade, you can always use \DebugBar::addMessage('This is a message'); etc. without injecting it first, as you have told Laravel how to resolve the class. This way you need not to use it first.

Upvotes: 4

red-rocket
red-rocket

Reputation: 162

Also make be sure that Barryvdh\Debugbar\ServiceProvider::class, is first in providers list.

Upvotes: 0

tapos ghosh
tapos ghosh

Reputation: 2202

if you want to show DebugBar this this process :

'providers' => [
    ...
    Barryvdh\Debugbar\ServiceProvider::class,
]

then

'aliases' => [
    ...
    'DebugBar' => Barryvdh\Debugbar\Facade::class,
]

then in your controller write

app('debugbar')->error('Watch out..');

now refresh browser then see the message enjoy

Upvotes: 7

barfoos
barfoos

Reputation: 753

I think the problem is, that you use the provider-array in a wrong way. It should be:

'providers' => [
    ...
    Barryvdh\Debugbar\ServiceProvider::class,
]

in your config/app.php. Also, please use the following instead of the string you wrote above:

'aliases' => [
    ...
    'DebugBar' => Barryvdh\Debugbar\Facade::class,
]

I tried your config on a clean Laravel-5 installation and it did not work. This is comes possibly with the absolute class paths. With the config listed above, it works very well.

Upvotes: 6

Related Questions