PHPackages                             selfphp/php-dependency-inspector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. selfphp/php-dependency-inspector

ActiveLibrary[CLI &amp; Console](/categories/cli)

selfphp/php-dependency-inspector
================================

CLI tool for analyzing, cleaning up, and monitoring Composer dependencies in PHP projects.

v1.4.0(11mo ago)431[2 issues](https://github.com/selfphp/php-dependency-inspector/issues)MITPHPPHP &gt;=8.1CI failing

Since May 30Pushed 11mo agoCompare

[ Source](https://github.com/selfphp/php-dependency-inspector)[ Packagist](https://packagist.org/packages/selfphp/php-dependency-inspector)[ RSS](/packages/selfphp-php-dependency-inspector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (0)

PHP Dependency Inspector
========================

[](#php-dependency-inspector)

**CLI tool for analyzing, cleaning up, and monitoring Composer dependencies in PHP projects.**

---

🚀 Commands
----------

[](#-commands)

### 🔍 analyse

[](#-analyse)

```
php bin/phpdi analyse [--path=...] [--only-unused] [--output=...]
```

OptionDescription`--path=...`Path to project root (default: current dir)`--only-unused`Show only packages that are not used in the codebase`--output=...`Export results to a Markdown file### 🛡 audit (for CI / Cron)

[](#-audit-for-ci--cron)

```
php bin/phpdi audit --output=report.md [--path=...] [--threshold=0] [--exit-on-unused] [--exit-on-outdated=minor|major] [--output-json=report.json] [--max-outdated=5] [--fail-if-total-packages-exceeds=100] [--no-ansi]
```

OptionDescription`--path=...`Project directory to analyze`--output=...`Write Markdown report to file`--output-json=...`Write JSON report to file`--threshold=...`Allow up to N unused packages before failing`--exit-on-unused`Return exit code `1` if unused packages exceed threshold`--exit-on-outdated`Set to `none`, `minor`, or `major` to fail (exit code `2`) on outdated deps`--max-outdated=...`Max number of outdated packages before failing with code `2``--fail-if-total-packages-exceeds=...`Fail with exit code `3` if total package count exceeds limit`--no-ansi`Disable ANSI colors (for CI log compatibility)#### Exit Codes

[](#exit-codes)

- `0`: All checks passed
- `1`: Too many unused packages
- `2`: Outdated packages violate threshold
- `3`: Total package count exceeds limit

---

✅ Example
---------

[](#-example)

```
php bin/phpdi audit --output=report.md --threshold=3 --exit-on-unused --exit-on-outdated=minor
```

---

ℹ️ Analysis Logic
-----------------

[](#ℹ️-analysis-logic)

As of `v1.4.0`, the tool **only analyzes production dependencies** listed under `require` in `composer.json`.
Development packages from `require-dev` are excluded from usage checks.

This ensures accurate reports for production readiness and avoids false positives from test-related packages like `phpunit/phpunit`.

---

🧪 Testing
---------

[](#-testing)

```
composer test
```

Runs PHPUnit tests for core functionality.

---

📦 Installation
--------------

[](#-installation)

```
composer install
```

Make sure you have a valid `composer.lock` file in your project root.

---

🔄 CI Integration
----------------

[](#-ci-integration)

### GitHub Actions

[](#github-actions)

`.github/workflows/dependency-audit.yml`

```
name: Dependency Audit
on: [push, pull_request]

jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.2
      - run: composer install
      - run: php bin/phpdi audit --exit-on-unused --exit-on-outdated=major --threshold=0
```

### GitLab CI

[](#gitlab-ci)

`.gitlab-ci.yml`

```
dependency-audit:
  image: php:8.2
  script:
    - apt-get update && apt-get install -y unzip git
    - curl -sS https://getcomposer.org/installer | php
    - php composer.phar install
    - php bin/phpdi audit --exit-on-unused --exit-on-outdated=major --threshold=0
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance41

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

5

Last Release

341d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d9da560cb003f45736b988e005afce3c17647553a1c1cea771b3cde3b7890ad1?d=identicon)[SELFPHP](/maintainers/SELFPHP)

---

Top Contributors

[![DamirEnseleit](https://avatars.githubusercontent.com/u/206047444?v=4)](https://github.com/DamirEnseleit "DamirEnseleit (6 commits)")[![selfphp](https://avatars.githubusercontent.com/u/12782362?v=4)](https://github.com/selfphp "selfphp (3 commits)")

---

Tags

phpcomposerclidependencyanalysisinspectorcleanupunused packagesoutdated packagesautomated audit

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/selfphp-php-dependency-inspector/health.svg)

```
[![Health](https://phpackages.com/badges/selfphp-php-dependency-inspector/health.svg)](https://phpackages.com/packages/selfphp-php-dependency-inspector)
```

###  Alternatives

[seregazhuk/php-watcher

Automatically restart PHP application once the source code changes

394137.8k4](/packages/seregazhuk-php-watcher)[renoki-co/php-helm

PHP Helm Processor is a process wrapper for Kubernetes' Helm v3 CLI. You can run programmatically Helm v3 commands, directly from PHP, with a simple syntax.

1310.5k](/packages/renoki-co-php-helm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
