# How to Retrieve the Full Laravel Route List: Complete Guide to Inspecting Application Endpoints

> Learn how to retrieve your full Laravel route list using php artisan route:list. Inspect all application endpoints and their actions with this complete guide.

- Repository: [Laravel/framework](https://github.com/laravel/framework)
- Tags: tutorial
- Published: 2026-02-21

---

**Use the `php artisan route:list` command to display every registered route, or access the router directly via `Route::getRoutes()` for programmatic inspection.**

When building or auditing a Laravel application, you often need to verify all available endpoints and their corresponding controllers or closures. The `laravel/framework` repository provides robust tooling to retrieve the full Laravel route list through both command-line and programmatic interfaces.

## Understanding the Route List Command Architecture

The `route:list` Artisan command is implemented in **[`src/Illuminate/Foundation/Console/RouteListCommand.php`](https://github.com/laravel/framework/blob/main/src/Illuminate/Foundation/Console/RouteListCommand.php)**. This command is automatically registered within the framework’s service container by **[`src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php`](https://github.com/laravel/framework/blob/main/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php)**, ensuring it is available in every Laravel application.

When executed, the command performs the following operations:

1. **Collects routes** from the router instance using `$this->router->getRoutes()`.
2. **Transforms each route** into a structured array containing the domain, HTTP methods, URI, name, action (controller or closure), and middleware via `getRouteInformation()`.
3. **Applies filtering** based on command-line options (`--method`, `--name`, `--action`, `--path`) in `filterRoute()`.
4. **Sorts** the collection (default by URI) using `sortRoutes()`.
5. **Formats** output for console display (`forCli()`) or JSON export (`asJson()`).

## How to Retrieve the Full Laravel Route List via CLI

### Displaying All Routes in a Table

To view every registered route in a formatted console table, run the following command from your project root:

```bash
php artisan route:list

```

This outputs a table with columns for **Domain**, **Method**, **URI**, **Name**, **Action**, and **Middleware**, allowing you to quickly scan your application’s endpoint structure.

### Exporting Routes to JSON

For programmatic consumption or documentation generation, export the route list as JSON:

```bash
php artisan route:list --json > routes.json

```

The `--json` flag triggers the `asJson()` method in [`RouteListCommand.php`](https://github.com/laravel/framework/blob/main/RouteListCommand.php), returning a machine-readable array of route objects.

### Filtering the Route Collection

When working with large applications, filter the output to locate specific endpoints:

```bash

# Show only GET routes

php artisan route:list --method=GET

# Find routes by name pattern

php artisan route:list --name=admin.*

# Filter by controller action

php artisan route:list --action=UserController@index

# Search by URI path

php artisan route:list --path=api/v1

```

These options map to the `filterRoute()` method, which validates each route against your criteria before display.

## Programmatically Accessing Route Information

### Using the Artisan Facade

To retrieve the full Laravel route list from within your application code, use the `Artisan` facade:

```php
use Illuminate\Support\Facades\Artisan;

// Execute the route:list command with JSON output
Artisan::call('route:list', ['--json' => true]);
$routes = json_decode(Artisan::output(), true);

// Iterate through routes
foreach ($routes as $route) {
    echo sprintf(
        "%s %s => %s\n",
        $route['method'],
        $route['uri'],
        $route['action']
    );
}

```

This approach leverages the same [`RouteListCommand.php`](https://github.com/laravel/framework/blob/main/RouteListCommand.php) logic while allowing you to process the results within your PHP code.

### Direct Router Access with the Route Facade

For custom processing without invoking Artisan, access the router directly:

```php
use Illuminate\Support\Facades\Route;

// Retrieve the raw RouteCollection
$routes = Route::getRoutes();

// Transform to array with custom formatting
$routeInfo = collect($routes)->map(function ($route) {
    return [
        'method'     => implode('|', $route->methods()),
        'uri'        => $route->uri(),
        'name'       => $route->getName(),
        'action'     => $route->getActionName(),
        'middleware' => $route->gatherMiddleware(),
        'domain'     => $route->getDomain(),
    ];
});

// Output for inspection
dd($routeInfo->toArray());

```

This method provides access to the underlying `Illuminate\Routing\Route` objects, exposing methods like `gatherMiddleware()` and `getDomain()` that may not appear in the standard CLI output.

## Summary

- The **`route:list`** Artisan command, implemented in [`RouteListCommand.php`](https://github.com/laravel/framework/blob/main/RouteListCommand.php), is the primary tool to retrieve the full Laravel route list.
- Use **`--json`** to export routes for programmatic consumption, or **`--method`**, **`--name`**, and **`--path`** filters to narrow results.
- Access routes programmatically via **`Artisan::call('route:list')`** or directly through **`Route::getRoutes()`** for custom inspection logic.
- The command sources data from the **`Router`** class in [`src/Illuminate/Routing/Router.php`](https://github.com/laravel/framework/blob/main/src/Illuminate/Routing/Router.php), ensuring consistency between CLI and programmatic access.

## Frequently Asked Questions

### Where is the route:list command implemented in Laravel?

The command is implemented in **[`src/Illuminate/Foundation/Console/RouteListCommand.php`](https://github.com/laravel/framework/blob/main/src/Illuminate/Foundation/Console/RouteListCommand.php)** within the `laravel/framework` repository. It is registered as a service in **[`src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php`](https://github.com/laravel/framework/blob/main/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php)**, making it available automatically in all Laravel applications.

### Can I filter routes by middleware using route:list?

The standard `route:list` command does not provide a dedicated `--middleware` filter option. However, middleware information is displayed in the output table under the **Middleware** column. To filter by middleware programmatically, use `Route::getRoutes()` and inspect the `gatherMiddleware()` method on each route object.

### How do I export my Laravel route list to JSON programmatically?

Use the `Artisan` facade to execute the command with the `--json` flag and capture the output:

```php
Artisan::call('route:list', ['--json' => true]);
$routes = json_decode(Artisan::output(), true);

```

This returns an array of route objects containing URI, method, action, and middleware details suitable for API documentation or automated testing tools.

### What is the difference between using Artisan::call and Route::getRoutes()?

**`Artisan::call('route:list')`** invokes the full command pipeline, applying filters, sorting, and formatting defined in [`RouteListCommand.php`](https://github.com/laravel/framework/blob/main/RouteListCommand.php), returning human-readable or JSON output. **`Route::getRoutes()`** provides direct access to the raw `RouteCollection` objects, allowing you to bypass command logic and implement custom filtering, formatting, or analysis without the overhead of the Artisan console.