Dwight Watson's blog

Route::currentRouteName() in Laravel 4.1

This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.

Worth noting that Route::currentRouteName() is no longer available in Laravel 4.1, likely a result of an Illuminate router replacing the Symfony router of the previous version. However, not all is lost! The new Illuminate router provides a lot of flexbility and while it might be a little more difficult to get the named route now there are a ton of new methods available to find out more about the route.

Route::current()->getName(); // Laravel 4.1's Route::currentRouteName();

So, Route::current() returns an instance of Illuminate\Routing\Route (from the Illuminate\Routing\Router/Route facade). It is definitely worth having a look through the API of both these classes to see what helpers are available (like Route::currentRouteNamed() to see if the current route is the one you specify) and to see what information you can access about the current route.

A blog about Laravel & Rails by Dwight Watson;

Picture of Dwight Watson

Follow me on Twitter, or GitHub.