davekoala/routes-explorer

Laravel package for exploring routes and their complete dependency chains

Maintainers

Package info

github.com/daveKoala/davekoala-routes-explorer

pkg:composer/davekoala/routes-explorer

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.4 2025-07-23 15:50 UTC

This package is auto-updated.

Last update: 2026-03-23 18:33:31 UTC


README

🔍 Explore Laravel routes and their complete dependency chains

Overview

Once installed open http://127.0.0.1/dev/routes-explorer

Laravel Archaeologist is a development tool designed to help new team members and existing developers explore and understand large Laravel applications.

Screen shot of routes and graph

It provides a clear, searchable interface to view:

  • Routes
  • Controllers
  • Models
  • Middleware
  • Traits
  • Class relationships

It also visualizes these relationships to make onboarding and refactoring easier.

Why?

When joining an existing Laravel project, understanding "what connects to what" can be painful. This tool makes that process easier by giving you immediate visibility into the routing structure and the classes behind it.

Patterns

How we discover class, traits, middleware, etc

  • Regex matches a pattern in the source code string
  • Extract the potential class name from the match
  • Build the full class name (usually by prepending App\Whatever)
  • Check if that class actually exists with class_exists()
  • Add to dependencies array if it exists

Here's the general pattern broken down:

// The pattern template:

if (preg_match_all('/PATTERN/', $source, $matches)) {
    foreach ($matches[1] as $capturedName) {
        // Build full class name
        $fullClass = "App\\Namespace\\{$capturedName}";
        // Verify it exists
        if (class_exists($fullClass)) {
            $dependencies[] = [
                'class' => $fullClass,
                'pattern' => 'what was matched',
                'usage' => 'type_of_usage'
            ];
        }
    }
}

So for example:

  • dispatch(new SendEmailJob()) → captures "SendEmailJob" → checks if App\Jobs\SendEmailJob exists
  • event(new OrderPlaced()) → captures "OrderPlaced" → checks if App\Events\OrderPlaced exists
  • User::create() → captures "User" → checks if App\Models\User exists

The class_exists() check is crucial because it prevents false positives. Without it, you might catch things like dispatch(new DateTime()) and try to analyze App\Jobs\DateTime which doesn't exist.

Todo

House keeping

  • Add configuration for things like 'max depth' list of classes to ignore
  • The Patterns in ClassAnalysisEngine.php as becoming too many, might be time to refactor
  • Test, now I know what it is I am building time to firm up the logic
  • Make sure this only runs in developmentmode

Next steps / feature

  • Add functionality to explore classes directly? Form to take full namespace and class name and(?) method?
  • How to turn this into a Composer package and publish? Time to show to people?

Installation

Install via Composer:

composer require davekoala/routes-explorer --dev

Then visit http://your-app.local/dev/routes-explorer in your browser.

Security

This package is designed for development environments only. It includes security middleware that restricts access to development environments (local, development, testing) and requires debug mode to be enabled.

Contributing / Support

  • Issues & Bug Reports: GitHub Issues
  • Questions & Discussions: GitHub Discussions
  • Contact: Feel free to reach out via GitHub for any questions or suggestions

License

This package is open-sourced software licensed under the MIT license.