zalanihir / deadcode-scanner
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
Requires
- php: ^8.2
- illuminate/support: ^12.0
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:
--detailsShow counts and extra info--jsonOutput 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).