定制 davekoala/routes-explorer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

davekoala/routes-explorer

最新稳定版本:v1.0.4

Composer 安装命令:

composer require davekoala/routes-explorer

包简介

Laravel package for exploring routes and their complete dependency chains

README 文档

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.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固