Prune
Prune (renfordt/prune) is a command-line tool that finds orphaned and unused PHP classes in your project through static AST analysis.
It parses your PHP files with nikic/php-parser, collects every class declaration and every class reference, and then reports the classes that are declared but never referenced anywhere in the scanned codebase. It can additionally detect unused Blade views in Laravel projects.
Work in progress - Prune is still heavily under development and should not be relied on in production. Always review its output before deleting anything — see Limitations & Risks.
What Prune does
- Scans one or more directories for PHP files.
- Builds a map of all declared classes, interfaces, traits, and enums.
- Collects every reference to those types (
extends,new, type hints, attributes, docblocks, and more). - Reports any declaration that is never referenced — an orphan.
- Optionally detects unused Blade views in Laravel projects.
- Outputs to a console table, JSON, or HTML.
- Returns a non-zero exit code when orphans are found, so it slots cleanly into CI.
Who it's for
Prune is built for developers and teams who want to keep a PHP codebase lean — spotting dead classes after a refactor, during a cleanup sprint, or as a recurring check in continuous integration.
Where to go next
| If you want to… | Read |
|---|---|
| Install and run Prune for the first time | Installation → Quick Start |
| Switch between console, JSON, and HTML | Output Formats |
| Find unused Blade views | Blade Analysis |
| Fail your pipeline on dead code | CI Integration |
| Tune what gets scanned | Configuration File · CLI Reference |
| Understand the analysis internals | How It Works |
| Know what Prune can't see | Limitations & Risks |
Requirements
- PHP 8.4 or newer
- Composer
License
Prune is released under the MIT License.