Hi, I just updated to the latest laravel-debugbar and now I'm getting 404 Not Found errors when loading
/_debugbar/assets.css?xxxxx
/_debugbar/assets.js?xxxxx
I can see that the routes are properly registered, but for some reason Nginx is not routing it correct. Could it be my Nginx config? Here is my config taken from the Server section below:
location / {
# URLs to attempt, including pretty ones.
try_files $uri $uri/ /index.php?$query_string;
}
# Remove trailing slash to please routing system.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# PHP FPM configuration.
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# We don't need .ht files with nginx.
location ~ /\.ht {
deny all;
}
# Set header expirations on per-project basis
location ~* \.(?:ico|css|js|jpe?g|JPG|png|svg|woff)$ {
expires 365d;
}
Do other routes work correctly? Is it possible to register routes that end with css or js?
Can you access them in your browser? Do you get an error from Laravel or just not found? Can you rename the routes to something without extension?
Hey there, same issue here.
I've tried to publish the assets didn't work either.
I am working with Apache2 and other routes are working correctly.
I am not able to access them in my browser - I'll get a 404 Not found. No error from laravel.
The only route set in routes.php is
Route::get('/', [ 'as' => 'index', 'uses' => 'IndexController@showIndex' ]);
Chrome's Error messages:
GET http://192.168.0.202/smhmlabor-new/public/_debugbar/assets.js?1409749183 404 (Not Found) 192.168.0.202/:61
GET http://192.168.0.202/smhmlabor-new/public/_debugbar/assets.css?1409749183 404 (Not Found) 192.168.0.202/:60
Uncaught ReferenceError: PhpDebugBar is not defined (index):64
So what should be the correct url? /smhmlabor-new/_debugbar/assets.css or /smhmlabor-new/public/index.php/_debugbar/assets.css?
I'm not really sure, the routes are just generated by the URL generator. If you try http://192.168.0.202/smhmlabor-new/public/_debugbar/javascript?1409749183, do you get a Laravel error then? Or without the ?123 query? Could be that apache doesn't send it to Laravel because it thinks it's a 'real' file.
/smhmlabor-new/public/index.php/_debugbar/assets.css with index.php does the trick.
I think otherwise it will, as mentioned, think it is a 'real' file.
But other routes work?
So does /smhmlabor-new/public/_debugbar/somelink give an Laravel error, or a 'plain' 404? Cause all routes should be caught with Laravel
/smhmlabor-new/public/_debugbar/somelinkreturns a 'plain' 404.
/smhmlabor-new/public/index.php/_debugbar/somelink returns a Laravel error.
But do all your normal routes work? Cause you don't have to prepend them with index.php do you? Do you normally use the URL generator to make your urls?
I've just recognized that the normal routes do not work either.
Mod Rewrite is enabled and the .htaccess file is correct.
Edit:
Okay it's propably my fault, I did not pay attention to the BasePaths for the Rewrite
Maybe you should access your app by going to /smhmlabor-new/public/index.php to make the routes also use index.php. Or perhaps tweak the rewrite, don't know how that is exactly for subdirectories.
But you could better set up a document root for each new app.
I've solved it by adding index.php after `/public/
Thanks for your help man! :)
Hi,
I have the same problem. I updated with the latest version also and i got this message : ReferenceError: Can't find variable: PhpDebugBar
In the previous version, the route was completely different and was working perfectly. Here, i can not access to the assets.js in the browser.
The url generated in my project is : http://local.ams.dev/_debugbar/assets.css?1409750117
Is it because i have a conflict with another route?
Thank you for your help.
So what do you get, a 404 from Apache/Nginx, a NotFoundException (or 404) from Laravel, or an error?
It shouldn't conflict, because it uses the _debugbar route prefix.
Does http://local.ams.dev/index.php/_debugbar/assets.css?1409750117 work?
Or if you get an Apache error, do you get a Laravel error page on http://local.ams.dev/_debugbar/javascript instead?
I get a NotFoundHttpException from Laravel when i try http://local.ams.dev/_debugbar/javascript
If i try to reach the link containing /index.php/ i get : Class 'Illuminate\Routing\Controller' not found
I have a lot of routes in my project and all of them seem to work.
And what kind of error do you get on the assets.css file?
Can you try renaming to to something without extension here:
https://github.com/barryvdh/laravel-debugbar/blob/master/src/ServiceProvider.php#L46
So something like this:
$this->app['router']->get('_debugbar/stylesheets', array(
'uses' => 'Barryvdh\Debugbar\Controllers\AssetController@css',
'as' => 'debugbar.assets.css',
));
$this->app['router']->get('_debugbar/scripts', array(
'uses' => 'Barryvdh\Debugbar\Controllers\AssetController@js',
'as' => 'debugbar.assets.js',
));
When i try to reach http://local.ams.dev/_debugbar/assets.css?1409750117
I get : FatalErrorException
Class 'Illuminate\Routing\Controller' not found
Same error message if i try to rename with our the extension.
What version of Laravel?
Version 4.0
Ah crap, Laravel change the namespace of the controller in 4.1
Oh! So i should upgrade from 4.0 to 4.1? Or could i specify a previous version of your debug bar in my composer.json?
I've pushed a change to allow the old controller: https://github.com/barryvdh/laravel-debugbar/commit/f365867944f03b1ded92371edc1745cce388ffff
Does that work for you? (Try updating to 1.7.x@dev in a few minutes)
Pushed another fix, does seem to work on 4.0 now. But I suggest you upgrade to 4.2 anytime when you get the chance ;)
Tagged v1.7.2, let me know if you still have problems with that release.
It works perfectly! Thanks for your help! I will upgrade Laravel soon ;)
I know this is closed, but I wanted to comment. I am having the same issue and cannot get passed it. Here are my lavarel (5-dev) routes:
$router->controller('auth', 'AuthController');
$router->get('api', function()
{
return 'hello, this my totally awesome api route!';
});
//route back to the default page for AngularJS to load
$router->any('{all}','AppController@index')->where('all', '.*');
$router->get('/', 'AppController@index');
What is happening is I get the following three errors, but they are all related to the assets not loading.
This next image shows that the default route for the laravel app is loading for the js and css assets instead of the actual css and js. All of the other assets load fine. The only difference is the js, css, and vendor folders are in the public folder of my laravel app. The _debugbar/ folder is dynamically generated at runtime. I have been trying to figure out how to get laravel to ignore that route (_debugbar). I thought your code would already do this and maybe it does, but I am not able to get it to work.
Any help would be appreciated.
The _debugbar routes shouldn't be ignored by Laravel, because they are rendered using Laravel. Open the javascript/stylesheets page in your browser and see what the error is. It should try to load and output the assets.
//$router->get('{path?}', 'AppController@index'); //wildcard route back to the default page for AngularJS to load
$router->any('{all}','AppController@index')->where('all', '.*');
http://connectv2.app/_debugbar/assets/stylesheets?1416797800
http://connectv2.app/_debugbar/assets/javascript?1416337314
When I put both of these directly in the url they get redirected back to the root url http://connectv2.app/ and this is the default action I want to occur so that angular will load correctly if someone enters the site at a folder within the site (….v2.app/folder/folder/). That route might equal something valid of course and would load correctly. Laravel is just acting at a “pass-thru” and the page routing is done by the client with angular.
If I uncommit the first route above and commit out the {all} route, then the page will load correctly and you can access the js and css files directly too. Hope all that makes sense. Thanks, Kevin
Hmm when I test that in L4.2, it does work. So I suppose app routes take precedence before my package routes. Can you switch the ServiceProviders (put debugbar first)?
That was it. I moved it from the very bottom to the top and now it works. Not sure if that is something you can fix or not. Currently running latest build of debugbar and laravel is version 5 (dev-master).
'providers' => [
/*
* Development Service Providers...
*/
'Way\Generators\GeneratorsServiceProvider',
'Barryvdh\Debugbar\ServiceProvider',
...
],
I don't really think so. I think in L4, the ServiceProviders run always before the routes.php is included, but in L5, the routes are loaded the same way as package service providers, so if you provide a catch-all, it will catch it before it ever reaches the package definitions.
But it might be worth to mention in the docs.
Sounds good, I appreciate you helping me get to the bottom of this. I hate to even tell you how long I messed with this until I found this thread.
Okay next time don't hesitate to open a new thread ;)
hi i know that it is old but, i have the same very issue, then i realize that my route was working with controller, instead of get, for example
Route::controller('/', 'MainController');
in this case i get a notFoundExeptiont, so, i have to move my routes to Route::get to get it work, but maybe it would be nice if it could work with controllers routes, because i don't like many route for my application instead of one file content the main routes, cheers
Hi,
I have thesame problem , i my case i resolve by activiting the apache rewrite module so that i would not need to type index.php after /public ( if when adding index.php after /public it work !!, it means we are dealing with thesame issue).
After updating composer, add the ServiceProvider to the providers array in config/app.php
If you use a catch-all/fallback route, make sure you load the Debugbar ServiceProvider before your own App ServiceProviders.
I fixed it with
php artisan cache:clear
Most helpful comment
After updating composer, add the ServiceProvider to the providers array in config/app.php