laravel 获取所有路由

直接代码:
以下代码同样用于lumen

use Illuminate\Http\Request;
use App\Core\Router;

class TestController
{
    public function getRouter() {
        $result = [];
        $routeCollection = \Route::getRoutes();
        foreach ($routeCollection as $row) {

            if ($row['uri'] == "/") {
                continue;
            }
            unset($row['action']);
            if (!isset($result[$row['uri']])) {
                $result[$row['uri']] = $row;
            }
        }
        foreach ($result as $row1) {
            print_r($row1);
        }
    }
}


你可能感兴趣的:(laravel 获取所有路由)