Skip to main content

CI Integration

Prune is designed to run in continuous integration. It exits with a non-zero status code when orphans are found, so any CI system can fail the build automatically.

Exit codeMeaning
0No orphans — codebase clean.
1At least one orphan found.

Add it to a script

The simplest integration is a Composer script. Add it to composer.json:

{
"scripts": {
"prune": "prune src"
}
}

Then run composer prune locally or in CI.

GitHub Actions

name: Prune
on: [push, pull_request]

jobs:
prune:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- run: composer install --no-interaction --prefer-dist
- run: php vendor/bin/prune src

The job fails if Prune reports any orphans.

GitLab CI

prune:
image: php:8.4-cli
script:
- composer install --no-interaction --prefer-dist
- php vendor/bin/prune src

Archiving the report

To keep a browsable record of each run, emit an HTML or JSON report and store it as a build artifact:

php vendor/bin/prune src --format=html --output=build/prune-report.html

Then point your CI's artifact configuration at build/prune-report.html.

tip

If your repository contains files with non-ASCII characters in their paths, make sure the CI environment uses a UTF-8 locale (e.g. LANG=C.UTF-8) so the parser handles them correctly.

Treat results as advisory

A failing Prune check flags candidates, not confirmed dead code. Before deleting anything a pipeline surfaces, review it against Limitations & Risks. For codebases with heavy dynamic dispatch, consider running Prune as a non-blocking informational step until you've tuned excludePaths and excludeViews.