zalanihir/deadcode-scanner

There is no license information available for the latest version (v1.0.0) of this package.

Automatic dead code and route scanner for Laravel

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/zalanihir/deadcode-scanner

v1.0.0 2025-10-08 18:54 UTC

This package is auto-updated.

Last update: 2025-12-08 19:34:55 UTC


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