Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Dead Code Detector

Dead Code Detector Laravel Package

shipmonk/dead-code-detector

PHPStan extension that detects and helps remove unused PHP code. Finds dead methods/properties/constants/enum cases, dead cycles and transitive dead members, even dead tested code. Supports popular frameworks like Symfony and is configurable via usage providers.

View on GitHub
Deep Wiki
Context7

💀 PHP unused code detection via PHPStan extension. Detects dead cycles, supports libs like Laravel, Symfony, Twig, Doctrine, PHPUnit etc. Can automatically remove dead PHP code. Able to detect dead code used only in tests. Finds unused methods, constants, properties and enum cases.

Frequently asked questions about Dead Code Detector
How do I install shipmonk/dead-code-detector for Laravel?
Run `composer require --dev shipmonk/dead-code-detector` and add `includes: - vendor/shipmonk/dead-code-detector/rules.neon` to your `phpstan.neon` file. No additional Laravel-specific setup is needed for basic usage.
Does this package work with Laravel’s Eloquent, events, or jobs?
Yes, it automatically detects dead code in Eloquent models, event listeners, jobs, and other Laravel patterns without manual configuration. Just run the analyzer on your full codebase (including tests).
Will this tool flag false positives for Laravel’s dynamic method calls (e.g., `app()->make()`)?
It can, but you can mitigate this by configuring custom `MemberUsageProvider` classes or excluding specific methods in `phpstan.neon`. The package supports Symfony’s DIC detection, which helps with Laravel’s service container.
Can I automatically remove dead code in Laravel, or should I review changes first?
You can use the `--error-format removeDeadCode` flag, but this is destructive. Test it in a branch first or use it as a warning-only check in CI. Always review removals manually before merging.
Does this package support detecting dead code used *only* in tests (e.g., test doubles, mocks)?
Yes, it detects dead code referenced exclusively in tests. However, analyze your entire codebase (src + tests) to ensure accurate results, as dead code might be used transitively.
How does this integrate with Laravel’s CI/CD pipeline (e.g., GitHub Actions)?
Add it to your CI workflow as a static analysis step. Use `vendor/bin/phpstan analyze` with `--memory-limit` flags for large projects. Fail builds on warnings or errors based on your team’s policy.
Are there Laravel-specific configurations I should add to phpstan.neon?
For Laravel, ensure `parameters.shipmonkDeadCode.usageProviders` includes Symfony’s container paths (if using `phpstan/phpstan-symfony`). Disable checks for dynamic patterns like `app()->make()` via exclusions if needed.
What Laravel versions and PHPStan versions does this package support?
It works with Laravel 8+ and PHPStan 1.0+. Check the [GitHub repo](https://github.com/shipmonk-rnd/dead-code-detector) for version-specific notes. Ensure your PHPStan version matches the package’s requirements.
Can I exclude certain classes/methods from dead code detection in Laravel?
Yes, use `parameters.shipmonkDeadCode.exclude` in `phpstan.neon` to exclude classes, methods, or namespaces. For example, exclude test-only classes or legacy code that’s intentionally unused.
What are the alternatives to shipmonk/dead-code-detector for Laravel?
Alternatives include PHPStan’s built-in `DeadCode` rule (less feature-rich), Psalm’s `UnusedCode` rule, or custom scripts with `phpmd` or `phpstan` + regex. This package stands out for its Laravel/Symfony integration and dead cycle detection.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope