PHPackages                             projecthanif/routescope - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. projecthanif/routescope

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

projecthanif/routescope
=======================

A Laravel package for route debugging and analysis.

2.0.1(6mo ago)7415MITBladePHP ^8.1

Since Dec 7Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/projecthanif/routescope)[ Packagist](https://packagist.org/packages/projecthanif/routescope)[ RSS](/packages/projecthanif-routescope/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (9)Versions (6)Used By (0)

RouteScope
==========

[](#routescope)

**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.

[![Latest Version on Packagist](https://camo.githubusercontent.com/cca04e071b1004841520f45d520a481a76e3f8750bd64afa91b40f84ef992175/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726f6a65637468616e69662f726f75746573636f70652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/projecthanif/routescope)[![Total Downloads](https://camo.githubusercontent.com/0966e10ac49ebb974511abfd1d694b69d137fdfbb54eafbc6ba479521b3accb5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726f6a65637468616e69662f726f75746573636f70652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/projecthanif/routescope)

Why RouteScope?
---------------

[](#why-routescope)

### 🔍 **Instant Route Visibility**

[](#-instant-route-visibility)

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.

### 🎯 **Smart Organization**

[](#-smart-organization)

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.

### 🚀 **Developer Productivity**

[](#-developer-productivity)

- **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

### 🛡️ **Production-Safe**

[](#️-production-safe)

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.

Installation
------------

[](#installation)

Install as a development dependency:

```
composer require projecthanif/routescope --dev
```

The package auto-registers via Laravel's service provider discovery. No additional setup required!

Quick Start
-----------

[](#quick-start)

Visit the dashboard in your browser:

```
http://localhost/routescope

```

That's it! You'll see all your routes organized, searchable, and ready to explore.

Configuration
-------------

[](#configuration)

Need to customize? Publish the configuration file:

```
php artisan vendor:publish --tag=routescope-config
```

Edit `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',
    ],
];
```

Features
--------

[](#features)

### 📊 Interactive Dashboard

[](#-interactive-dashboard)

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

### 🔌 Programmatic Access

[](#-programmatic-access)

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
]
```

### 🎨 Smart Categorization

[](#-smart-categorization)

Routes are automatically organized:

- **API Routes**: Everything under `/api/*`
- **Web Routes**: Your standard web application routes

### ⚙️ Flexible Filtering

[](#️-flexible-filtering)

Exclude routes you don't care about:

- Debug tools (Telescope, Ignition)
- Internal Laravel routes
- Third-party package routes
- Custom patterns you define

### 🔒 Type-Safe

[](#-type-safe)

Built with strict typing and comprehensive type hints for a better development experience with IDE autocomplete and static analysis tools.

Usage Examples
--------------

[](#usage-examples)

### View All Routes in a Custom Command

[](#view-all-routes-in-a-custom-command)

```
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']}");
        }
    }
}
```

### Find Routes with Specific Middleware

[](#find-routes-with-specific-middleware)

```
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();
```

### Generate API Documentation

[](#generate-api-documentation)

```
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);
```

### Dependency Injection in Controllers

[](#dependency-injection-in-controllers)

```
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'));
    }
}
```

API Reference
-------------

[](#api-reference)

### `RouteScope::getAllRoutes(): array`

[](#routescopegetallroutes-array)

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
    ]
]
```

Environment Variables
---------------------

[](#environment-variables)

```
# Enable/disable the package (automatically disabled in production)
ROUTESCOPE_ENABLED=true

# Customize the dashboard URL prefix
ROUTESCOPE_PREFIX=routescope
```

Production Safety
-----------------

[](#production-safety)

RouteScope is designed to be safe by default:

1. **Auto-disabled in production** - The default configuration only enables RouteScope in local/development environments
2. **Dev dependency** - Install with `--dev` to exclude from production builds
3. **Lightweight** - Zero runtime overhead when disabled
4. **No database** - Purely reads from Laravel's route collection

To ensure it's disabled in production, add to `.env.production`:

```
ROUTESCOPE_ENABLED=false
```

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.0 or higher
- Illuminate/Support package

Use Cases
---------

[](#use-cases)

### 🐛 **Debugging**

[](#-debugging)

"Why isn't my route working?" - See instantly if the route exists, what middleware is blocking it, and where it's defined.

### 📚 **Documentation**

[](#-documentation)

Generate comprehensive route documentation for your team or API consumers programmatically.

### 👥 **Onboarding**

[](#-onboarding)

New developers can explore your application's API surface without diving into route files.

### 🔍 **Auditing**

[](#-auditing)

Quickly identify which routes lack authentication, have duplicate definitions, or use deprecated middleware.

### 🏗️ **Refactoring**

[](#️-refactoring)

When restructuring your application, see the full scope of route changes in one place.

Testing
-------

[](#testing)

```
composer test           # Run all tests
composer test:lint      # Code style checks
composer test:types     # Static analysis
composer test:unit      # Unit tests
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Ibrahim Mustapha](https://github.com/projecthanif)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE.md](./LICENSE.md) for more information.

---

**RouteScope** - See your routes clearly. Debug confidently. Build faster.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance66

Regular maintenance activity

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

207d ago

Major Versions

1.0.1 → 2.0.02025-12-07

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/121246102?v=4)[Ibrahim Mustapha Alhaji](/maintainers/projecthanif)[@projecthanif](https://github.com/projecthanif)

---

Top Contributors

[![projecthanif](https://avatars.githubusercontent.com/u/121246102?v=4)](https://github.com/projecthanif "projecthanif (12 commits)")

---

Tags

debuggingdeveloper-toolslaravellaravel-packagephproutingphplaravelpackagedebugginganalysisrouteroute-debuggingroute-analysisroute lensroutescopelaravel route lens

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/projecthanif-routescope/health.svg)

```
[![Health](https://phpackages.com/badges/projecthanif-routescope/health.svg)](https://phpackages.com/packages/projecthanif-routescope)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k55.4M8.3k](/packages/larastan-larastan)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M129](/packages/roots-acorn)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M1](/packages/glushkovds-phpclickhouse-laravel)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

15118.7k4](/packages/calebdw-larastan)[itpathsolutions/dbstan

Database Standardization and Analysis Tool for Laravel

442.1k](/packages/itpathsolutions-dbstan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
