且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Laravel 5 如何获取路由操作名称?

更新时间:2023-11-26 10:14:10

在 Laravel 5 中,您应该使用方法或构造函数注入.这将执行您想要的操作:

In Laravel 5 you should be using Method or Constructor injection. This will do what you want:

<?php namespace AppHttpControllers;

use IlluminateRoutingRoute;

class HomeController extends Controller
{
    public function getIndex(Route $route)
    {
        echo 'getIndex';
        echo $route->getActionName();
    }
}