How to get a list of registered route paths in Laravel?

In Laravel, you can retrieve a list of all registered route paths using several methods. All routes are stored in the routes/ folder, and you'll need to include the Route facade to work with them ?

Make sure Laravel is installed and configured properly before running these examples.

Using Artisan Command

The simplest way to view all routes is using the artisan command ?

php artisan route:list
+--------+----------+---------------------+------+-------------------------------------------------------------+------------------------------------------+
| Domain | Method   |     URI             | Name |             Action                                          |          Middleware                      |
+--------+----------+---------------------+------+-------------------------------------------------------------+------------------------------------------+
|        | GET|HEAD | /                   |      |          Closure                                            | web                                      |
|        | GET|HEAD | api/user            |      |          Closure                                            | api                                      |
|        | GET|HEAD | test                |      | App\Http\Controllers\StudentController@index                | web                                      |
|        | GET|HEAD | users               |      | App\Http\Controllers\UserController@index                   | web                                      |
|        | POST     | validation          |      | App\Http\Controllers\testvalidationController@validateform  | web                                      |
+--------+----------+---------------------+------+-------------------------------------------------------------+------------------------------------------+

Hide Middleware Column

To exclude the middleware column from the output, use the v flag ?

php artisan route:list -v

Using getRoutes() Method

You can programmatically access routes using the getRoutes() method, which returns a RouteCollection that can be looped through ?

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;

class RouteController extends Controller {
    public function index(Router $route) {
        $routes = $route->getRoutes();
        foreach ($routes as $value) {
            echo $value->uri();
            echo "<br/>";
        }
    }
}
?>
api/user
/
test
users
validation

Using Route Facade

You can also use the Route facade directly in your routes file to get route information ?

<?php
use Illuminate\Support\Facades\Route;

Route::get('/routes', function() {
    $routeCollection = Route::getRoutes();
    foreach ($routeCollection as $value) {
        echo $value->getActionName();
        echo "<br/>";
    }
});
?>
Closure
App\Http\Controllers\StudentController@index
App\Http\Controllers\UserController@index
App\Http\Controllers\testvalidationController@showform

Conclusion

Use php artisan route:list for quick command-line inspection, or the getRoutes() method for programmatic access to route information within your application.

Updated on: 2026-03-15T10:12:41+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements