定制 zalanihir/deadcode-scanner 二次开发

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

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

zalanihir/deadcode-scanner

最新稳定版本:v1.0.0

Composer 安装命令:

composer require zalanihir/deadcode-scanner

包简介

Automatic dead code and route scanner for Laravel

README 文档

README

Automatic dead code and route scanner for Laravel applications.

Installation

composer require zalanihir/deadcode-scanner --dev

Laravel auto-discovers the service provider via extra.laravel.providers.

Optionally publish the config:

php artisan vendor:publish --tag=deadcode-config

Usage

php artisan deadcode:scan

Options:

  • --details Show counts and extra info
  • --json Output JSON report to stdout

What it checks

  • Routes pointing to missing controllers/methods
  • Unused public controller methods under app/Http/Controllers
  • Unused Blade views (resources/views)
  • Undefined routes referenced in Blade via route('name')

Ignoring items

After publishing the config (config/deadcode.php):

return [
    'ignore' => [
        'routes' => [
            // route names or URIs
            'login',
            'healthz',
        ],
        'controllers' => [
            // fully-qualified controller classes
            App\Http\Controllers\Internal\WebhookController::class,
        ],
        'controller_methods' => [
            // method names or FQCN::method
            'helper',
            App\Http\Controllers\UserController::class . '::legacy',
        ],
        'views' => [
            // dot-notation view names
            'errors::404',
            'emails.welcome',
        ],
    ],
];

Notes

  • Heuristics are conservative; review before deleting code.
  • Scans only literal references (no runtime/generated view names).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-09-21