A powerful route inspection tool for Laravel developers.
RouteScope gives you instant visibility into your application's routing layer. Stop guessing which routes exist, what middleware they use, or where they're defined. See everything at a glance with an elegant dashboard or query routes programmatically.
Ever wondered "Does this route actually exist?" or "What middleware is protecting this endpoint?" RouteScope answers these questions instantly with a clean, organized view of every route in your application.
Routes are automatically categorized into API and web routes, making it easy to understand your application's structure at a glance. No more scrolling through php artisan route:list output.
- Debug faster - Quickly identify routing issues and middleware conflicts
- Onboard easier - New team members can explore the API surface in minutes
- Document better - Generate route documentation programmatically
- Refactor confidently - See the full scope of changes when restructuring routes
Built with safety in mind. RouteScope automatically disables itself in production environments and can be installed as a dev dependency to keep your production builds lean.
Install as a development dependency:
composer require projecthanif/routescope --devThe package auto-registers via Laravel's service provider discovery. No additional setup required!
Visit the dashboard in your browser:
http://localhost/routescope
That's it! You'll see all your routes organized, searchable, and ready to explore.
Need to customize? Publish the configuration file:
php artisan vendor:publish --tag=routescope-configEdit config/routescope.php:
return [
// Only enable in local/development environments
'enabled' => env('ROUTESCOPE_ENABLED', app()->environment('local', 'development')),
// Customize the dashboard URL
'prefix' => env('ROUTESCOPE_PREFIX', 'routescope'),
// Hide routes you don't want to see (debug tools, internal routes, etc.)
'excluded_patterns' => [
'routescope',
'_ignition',
'sanctum/csrf-cookie',
'telescope',
'horizon',
],
];A beautiful, responsive interface that displays:
- HTTP methods (GET, POST, PUT, DELETE, PATCH)
- Route URIs and named routes
- Controller actions or closure definitions
- Applied middleware chains
- Quick search and filtering
Query routes from your code using the facade or dependency injection:
use Projecthanif\RouteScope\Facades\RouteScope;
$routes = RouteScope::getAllRoutes();
// Returns:
[
'apiRoutes' => [...], // All /api/* routes
'webRoutes' => [...] // All other routes
]Routes are automatically organized:
- API Routes: Everything under
/api/* - Web Routes: Your standard web application routes
Exclude routes you don't care about:
- Debug tools (Telescope, Ignition)
- Internal Laravel routes
- Third-party package routes
- Custom patterns you define
Built with strict typing and comprehensive type hints for a better development experience with IDE autocomplete and static analysis tools.
use Projecthanif\RouteScope\Facades\RouteScope;
class InspectRoutes extends Command
{
public function handle()
{
$all = RouteScope::getAllRoutes();
$this->info('API Routes:');
foreach ($all['apiRoutes'] as $route) {
$this->line(" {$route['method']} {$route['path']}");
}
$this->info('Web Routes:');
foreach ($all['webRoutes'] as $route) {
$this->line(" {$route['method']} {$route['path']}");
}
}
}use Projecthanif\RouteScope\Services\RouteScopeService;
$service = app(RouteScopeService::class);
$routes = $service->getAllRoutes();
$authRoutes = collect($routes['webRoutes'])
->filter(fn($route) => in_array('auth', $route['middleware']))
->all();use Projecthanif\RouteScope\Facades\RouteScope;
$routes = RouteScope::getAllRoutes();
$markdown = "# API Endpoints\n\n";
foreach ($routes['apiRoutes'] as $route) {
$markdown .= "### {$route['method']} {$route['path']}\n\n";
$markdown .= "**Controller**: `{$route['source']}`\n";
$markdown .= "**Middleware**: " . implode(', ', $route['middleware']) . "\n\n";
}
file_put_contents('api-docs.md', $markdown);use Projecthanif\RouteScope\Services\RouteScopeService;
class RouteAnalysisController extends Controller
{
public function __construct(
private RouteScopeService $routeScope
) {}
public function index()
{
$routes = $this->routeScope->getAllRoutes();
return view('admin.routes', compact('routes'));
}
}Returns all routes organized into API and Web categories.
Response Structure:
[
'apiRoutes' => [
[
'method' => 'GET|POST|PUT|DELETE|PATCH',
'path' => '/api/users',
'name' => 'users.index', // or null if unnamed
'source' => 'App\Http\Controllers\UserController::index',
'middleware' => ['api', 'auth:sanctum'],
],
// ... more routes
],
'webRoutes' => [
[
'method' => 'GET',
'path' => '/dashboard',
'name' => 'dashboard',
'source' => 'App\Http\Controllers\DashboardController::show',
'middleware' => ['web', 'auth'],
],
// ... more routes
]
]# Enable/disable the package (automatically disabled in production)
ROUTESCOPE_ENABLED=true
# Customize the dashboard URL prefix
ROUTESCOPE_PREFIX=routescopeRouteScope is designed to be safe by default:
- Auto-disabled in production - The default configuration only enables RouteScope in local/development environments
- Dev dependency - Install with
--devto exclude from production builds - Lightweight - Zero runtime overhead when disabled
- No database - Purely reads from Laravel's route collection
To ensure it's disabled in production, add to .env.production:
ROUTESCOPE_ENABLED=false- PHP 8.1 or higher
- Laravel 10.0 or higher
- Illuminate/Support package
"Why isn't my route working?" - See instantly if the route exists, what middleware is blocking it, and where it's defined.
Generate comprehensive route documentation for your team or API consumers programmatically.
New developers can explore your application's API surface without diving into route files.
Quickly identify which routes lack authentication, have duplicate definitions, or use deprecated middleware.
When restructuring your application, see the full scope of route changes in one place.
composer test # Run all tests
composer test:lint # Code style checks
composer test:types # Static analysis
composer test:unit # Unit testsContributions are welcome! Please see CONTRIBUTING.md for details.
If you discover any security-related issues, please email iamustapha213@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see LICENSE.md for more information.
RouteScope - See your routes clearly. Debug confidently. Build faster.