Named Routes Not Working In Laravel 5.2?

- 1 answer

I have some named routes using the as parameter. Seems to work fine in 5.1, but when I use the same package in 5.2 it throws an error:

ErrorException in UrlGenerator.php line 307:
Route [/blog] not defined. (View: ...)

I've cleared all the caches to no avail.

php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan config:clear

Have dumped:

composer dump-autoload

But still doesn't work. When I do a php artisan route:list it seems ok to me:

| Domain | Method   | URI              | Name       | Action                                                         | Middleware |
|        | GET|HEAD | blog             | blog       | ...                                                            |            |
|        | GET|HEAD | blog/feed        | feed       | ...                                                            |            |

EDIT: To clarify one thing. I'm definitely using route('blog') when trying to generate the route. It's also working in Laravel 5.1 just fine. Not to mention it's with ALL the named routes not just blog in the particular example I presented.



Your error message is saying that you're trying to access a route with the name "/blog", however, your route is named "blog" (no slash). Somewhere you have the code route('/blog'), and this is causing your error; it should be route('blog').