Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

untymage's avatar

How to get a list of registered route in specific route file

Is it possible to get all registered route only in web.php not on any other files like api, ?

0 likes
4 replies
Nakov's avatar
Nakov
Best Answer
Level 73

@untymage

$routes = [];

foreach (Route::getRoutes()->getIterator() as $route){
    if (strpos($route->uri, 'api') === false){
        $routes[] = $route->uri;
    }
}

dd($routes);
junaidahmed's avatar

@Nakov hi I have 1 years on laravel I search getIterator in documentation even getRoutes not find in laravel routing documentation find through google how you find these function through documentation please guid me

Please or to participate in this conversation.