Laravel 5 how to get route action name?

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Understanding Route Actions in Laravel 5 - Retrieving Action Names Laravel is a popular PHP framework that provides various tools to make building web applications easier. The routing system is an essential part of any MVC-based application, and the ability to retrieve the current route's action name can be useful for debugging or logging purposes. In this blog post, we'll discuss how you can get the route action name in Laravel 5, as well as provide some tips on handling routes more efficiently. 1. The Correct Approach in Laravel 5: In order to get the current route's action name, first of all, we need to understand the changes made from Laravel 4 to 5. In Laravel 5, `Route::currentRouteAction()` has been deprecated and replaced with a different approach. The new method used to retrieve the current route's action is named `action`.
<?php namespace App\Http\Controllers;

use Illuminate\Routing\Route;

class HomeController extends Controller
{
    public function getIndex()
    {
        echo 'getIndex';
        echo Route::currentRouteAction(); // Replaced with "action"
    }
}
2. Understanding the Difference: Laravel 4's `Route::currentRouteAction()` would return the controller and method name as a string, like 'MyController@myMethod'. In contrast, Laravel 5's `action` function returns a more structured format, which includes the full namespace, class name, method name, and any other relevant information. For example:
<?php namespace App\Http\Controllers;

use Illuminate\Routing\Route;

class HomeController extends Controller
{
    public function getIndex()
    {
        echo 'getIndex';
        echo Route::currentRouteAction(); // Replaces with "action"
    }
}
Output: 'App\Http\Controllers\HomeController@getIndex' 3. Using the action Function: Using `action` will give you the entire route's action name, but sometimes you may only want to extract a specific part of it. To do this, we can use the `route()` function together with `action`. For instance, let's say we only need the class and method names:
<?php namespace App\Http\Controllers;

use Illuminate\Routing\Route;

class HomeController extends Controller
{
    public function getIndex()
    {
        echo 'getIndex';
        $controllerAndMethod = Route::current()->getActionName(); // Returns controller@method name
        $controllerOnly = Route::current()->getControllerName(); // Returns only the controller name
        $methodOnly = Route::current()->getMethodName(); // Returns only the method name
    }
}
4. Final Thoughts: Although `Route::getActionName()` doesn't exist in Laravel 5, you can still extract various parts of your current route action with the help of other methods provided by the framework. By using `action`, `getActionName()`, `getControllerName()`, and `getMethodName()`, you can get different combinations of information about your route. Remember to use these functions wisely in order to achieve your desired results efficiently and maintain a clean code structure.