Laravel-debugbar: PhpDebugBar is not defined - Laravel 5.1

Created on 18 Aug 2015  路  47Comments  路  Source: barryvdh/laravel-debugbar

Hi, I know that a similar issue has been solved before, but I tried to follow the same suggested procedures but none of them worked for me. I'm using Laravel 5.1 .

I'm getting the following 404 not found errors :

<http://my_website_url/_debugbar/assets/stylesheets?1436453519>
<http://my_website_url/_debugbar/assets/javascript?1423122680>

and <PhpDebugBar is not defined>

I put debugbar first in the ServiceProviders and I don't have a catchall in my routes. The only thing I have in my routes is the following:
<Route::get('/', 'WelcomeController@index');>

Most helpful comment

  1. Check your apache config:
<Directory ***>
AllowOverride All
Allow from all
</Directory>
  1. Activate mod_rewrite:

a2enmod rewrite

All 47 comments

+1

I'm also experiencing this issue. I solved this by adding 2 routes in the RouteServiceProvider.

$router->get( '/_debugbar/assets/stylesheets', '\Barryvdh\Debugbar\Controllers\AssetController@css' );
$router->get( '/_debugbar/assets/javascript', '\Barryvdh\Debugbar\Controllers\AssetController@js' );

I don't know if this is the best 'solution', but it works for me.

@mikevrind thanks for your response but it didn't work on my side

Same problem , Any solution ?

+1 Should be fixed.

Here's a variant of @mikevrind solution that worked for me. Added this to my app/Http/routes.php:

Route::get('/_debugbar/assets/stylesheets', [
    'as' => 'debugbar-css',
    'uses' => '\Barryvdh\Debugbar\Controllers\AssetController@css'
]);

Route::get('/_debugbar/assets/javascript', [
    'as' => 'debugbar-js',
    'uses' => '\Barryvdh\Debugbar\Controllers\AssetController@js'
]);

Its not working for me with that fix aswell,

its working fine for old projects but for a project i created yesterday its not working.

@pbrisson Work for me thanks ,

Laravel version 5.1.10 (LTS)
"barryvdh/laravel-debugbar": "^2.0"

providers:
BarryvdhDebugbarServiceProvider::class,

alias
BarryvdhDebugbarServiceProvider::class,

Found out that another one might be required for AJAX calls (open handler).

According to this, complete app/Http/routes.php would now be:

Route::get('/_debugbar/assets/stylesheets', [
    'as' => 'debugbar-css',
    'uses' => '\Barryvdh\Debugbar\Controllers\AssetController@css'
]);

Route::get('/_debugbar/assets/javascript', [
    'as' => 'debugbar-js',
    'uses' => '\Barryvdh\Debugbar\Controllers\AssetController@js'
]);

Route::get('/_debugbar/open', [
    'as' => 'debugbar-open',
    'uses' => '\Barryvdh\Debugbar\Controllers\OpenController@handler'
]);

may be this helps in debugging....

those errors coming up after running php artisan view:clear

i have a project in which debugbar exists for many months and working perfectly but just now i hit above command and problem started again.

ofcourse writing above code into routes.php fixes issue.

I have been using the debugbar with Laravel 5.1 for some weeks without incident - this problem only arose for me today too (I am now on v. 5.1.17)

@pbrisson Thanks for posting your patch - very helpful!

I have this issue in Lumen

The above patches are, unfortunately, no longer working for me (Debugbar v2.0.6 and Laravel v5.1.17). I too keep running up against the following:

http://localhost/_debugbar/assets/javascript?1423122680

Right now I have to turn off the debugbar to allow views to fully load, turning it back on only when I run into an error (so I can reload the error page with more info). Wondering if anyone has come up with a new workaround? Thanks!

@mpmurph for me even if i go to /vendor/..../config/debugbar.php and i change the route_prefix to something else like http://localhost/_got_something_new/assets/javascript?1423122680 it just never seems to find those assets. I have given up on it until a fix comes - just reverting to good old dd().

Thanks, @hasokeric! Will likely do the same!

Can someone create a working test case that I can easily run, so I can reproduce this?

Hi @barryvdh - I am pretty new to this so am not sure if this will help... I just created a new Laravel app. The only change I made was to require barryvdh/laravel-debugbar and then register the service provider and alias in app.php. I then tried to load the app on localhost (using MAMP) and got the Laravel 5 default home page to come up but the page doesn't stop loading and the 'scripts' panel of Firebug pops up with the javascript?1423122680() error as I have been getting in my app proper. The little loading message seems to be stuck at "Transferring data from fonts.gstatic.com" - perhaps that gives a clue as to the problem?

I have loaded up this fake app to github here: https://github.com/mpmurph/jserror - the .env file is the Laravel default and I removed it from .gitignore so if you want to fork the repo, the only thing you would have to do is build the vendor folder.

I am not sure if this is a good enough working test case scenario - or if it's what you had in mind - I'm still pretty new to coding and to Laravel. Let me know if there's anything else I can do to help! Thank you!

p.s. Here's a screenshot of what Firebug is outputting at the breakpoint:

2015-09-30 08 15 24 pm

@barryvdh Update: I think the problem is only occurring in Firefox. Chrome and Safari seem to be working fine with the debugbar.

@barryvdh Suspecting this might actually be a Firebug problem! I have it on pretty much all the time for debugging but, turning it off, the pages are loading fine in Firefox with the debugbar.

I am wondering if others on this thread can also trace this problem to using Firebug 2.0.12 (released Sep. 2)?

I have the same problem using Chrome.

This problem appears when we set Route::controller('/', 'SomeController') in our routes.php file. Laravel create {_missing} route before package routes, and it matches everything to not found.
laravel
This is more likely Laravel problem.

Did you check your apache config and changed the Directory www to AllowOverride all?

I was having this problem due to a wildcard route.

Route::get('{page}', ['as' => 'page', 'uses' => '\Cms\Controllers\PageController@page'])->where(['page' => '(.*?)']);

It was capturing the requests for the JS/CSS causing the "PhpDebugBar is not defined" JS error.

When doing php artisan route:list my wildcard route (above) is the one at the very bottom. Does this mean Laravel is reading from the bottom up?

Installed latest Laravel and DebugBar today, running on WAMP (Windows 8.1, Apache 2.4.9, MySQL 5.6.17, PHP 5.5.12).

DebugBar didn't show up in welcome view, css / js were not found. Firefox console threw out errors:

ReferenceError: jQuery is not defined
ReferenceError: PhpDebugBar is not defined

Tried clearing cache, adding custom route, etc. - nothing worked.

Solution was to add a RewriteBase /LaraTest/public/ to my .htaccess file (after RewriteEngine On).

After refresh, the bar showed up immediately when I entered http://localhost/LaraTest/public/ into my browser address bar (Firefox 40).

Same problem, guys helps!

adding the routes to serviceprovider works for me. should be fixed.

days85 hit the nail on the head. Using OSX server, you have to use the advanced button and check off .htaccess over-ride. Once you start adding routes and other stuff this becomes obvious, but with a fresh install, not so much.

@days85 i was missing AllowOverride all from my vhost config, that solved it.

I'm happy that this worked for some of you.

Same issue here with Laravel 5.2.14

Hi everyone, same issue, i was missing AllowOverride all, once activated everything started to work properly

same here

  1. Check your apache config:
<Directory ***>
AllowOverride All
Allow from all
</Directory>
  1. Activate mod_rewrite:

a2enmod rewrite

Adding "Rewritebase /" after "RewriteEngine on" in "public/.htaccess" worked for me.

I am using xampp. I have enabled rewrite and vhost. DocumentRoot directive is pointing to 'H:/htdocs/xxx/public'.

If you are caching your routes and enable and disable debugbar, your route cache might loose debugbar's routes. Try
php artisan route:cache
it worked fine for me.

Late to the party on this but I installed the package for the first time and I think it would be helpful to add a note about the Route configuration to the github readme.md file.

Same problem , Any solution ?
Laravel 5.4 / localhost LAMP
error console
GET http://www.my.my/_debugbar/assets/stylesheets?v=1497426284
GET http://www.my.my/_debugbar/assets/javascript?v=1497426284
GET http://www.my.my/_debugbar/assets/stylesheets?v=1497426284
GET http://www.my.my/_debugbar/assets/javascript?v=1497426284
Uncaught ReferenceError: PhpDebugBar is not defined
at (index):87

If the dev environment of your laravel project is using the default configuration of Apache for web root directory , make sure the AllowOverride All is set for the web root directory.

<Directory "/var/www/html">
   ...
   AllowOverride All 
   ...
</Directory>

Restart web service and try reloading the page. The debug bar should be showing up properly.

thanks ojikobeshi

Thanks @avatar-test
In my case the module rewrite was disabled, just enable and already solved the problem

solution

a2enmod rewrite

Thanks, this is still broken. This took me waaaay too long to find.

Deleting it from all my projects..

If mod rewrite is disabled, all the Laravel rewriting probably doesn't work. So not really sure why this is an issue with debugbar.

Just for the record, I had the same problem and realised I made a silly mistake: I injected DebugBar code in my views without checking the proper config options. Here's my updated code:

<?php $debugbar_enabled = config("debugbar.enabled") ?? true; ?>
@if(config("app.debug") == true && $debugbar_enabled)
    <?php
        $renderer = \Debugbar::getJavascriptRenderer();
    ?>
    {!! $renderer->renderHead() !!}
    {!! $renderer->render() !!}
@endif

Hope this helps!

may be this helps in debugging....

those errors coming up after running php artisan view:clear

i have a project in which debugbar exists for many months and working perfectly but just now i hit above command and problem started again.

ofcourse writing above code into routes.php fixes issue.

This is useful to me, thank you very much!

I'm also experiencing this issue. I solved this by adding 2 routes in the RouteServiceProvider.

$router->get( '/_debugbar/assets/stylesheets', '\Barryvdh\Debugbar\Controllers\AssetController@css' );
$router->get( '/_debugbar/assets/javascript', '\Barryvdh\Debugbar\Controllers\AssetController@js' );

I don't know if this is the best 'solution', but it works for me.

This worked for me while on Laravel version 5.2.45, Thank You!

I cleaned the cache on my browser and it fixed it :P

I'm also experiencing this issue. I solved this by adding 2 routes in the RouteServiceProvider.

$router->get( '/_debugbar/assets/stylesheets', '\Barryvdh\Debugbar\Controllers\AssetController@css' );
$router->get( '/_debugbar/assets/javascript', '\Barryvdh\Debugbar\Controllers\AssetController@js' );

I don't know if this is the best 'solution', but it works for me.

When put its on web.php .not working debugbar

Was this page helpful?
0 / 5 - 0 ratings

Related issues

damienfern picture damienfern  路  4Comments

thomthom picture thomthom  路  5Comments

njbarrett picture njbarrett  路  5Comments

coderdiaz picture coderdiaz  路  4Comments

MRZ2017 picture MRZ2017  路  3Comments