PHPackages                             icanhazstring/composer-unused - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. icanhazstring/composer-unused

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

icanhazstring/composer-unused
=============================

Show unused packages by scanning your code

0.9.6(3mo ago)1.7k7.0M—3.6%57[10 issues](https://github.com/composer-unused/composer-unused/issues)[3 PRs](https://github.com/composer-unused/composer-unused/pulls)20MITPHPPHP ^8.1CI passing

Since Mar 23Pushed 1mo ago7 watchersCompare

[ Source](https://github.com/composer-unused/composer-unused)[ Packagist](https://packagist.org/packages/icanhazstring/composer-unused)[ Docs](https://github.com/composer-unused/composer-unused)[ GitHub Sponsors](https://github.com/sponsors/icanhazstring)[ Fund](https://paypal.me/icanhazstring)[ RSS](/packages/icanhazstring-composer-unused/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (30)Versions (54)Used By (20)

 [![composer-unused logo](https://raw.githubusercontent.com/composer-unused/composer-unused/main/art/logo.png)](https://raw.githubusercontent.com/composer-unused/composer-unused/main/art/logo.png)

composer-unused
===============

[](#composer-unused)

A Composer tool to show unused Composer dependencies by scanning your code.

Created by [Andreas Frömer](https://twitter.com/icanhazstring) and [contributors](https://github.com/composer-unused/composer-unused/graphs/contributors), logo by [Caneco](https://twitter.com/caneco).

[![](https://camo.githubusercontent.com/d842d95130b9cd997b28451e16a48ccffcd342cc652394c02e172a27cce9afdc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f6d706f7365722d756e757365642f636f6d706f7365722d756e757365642f76616c69646174652d636f64652e796d6c3f6272616e63683d6d61696e266c6162656c3d6275696c64267374796c653d666c61742d737175617265)](https://github.com/composer-unused/composer-unused)[![](https://camo.githubusercontent.com/3ae1c6dfeaa3e6ba86acac999598b12e84fdd8aa73395f8eef84011371c8b6a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f6d706f7365722d756e757365642f636f6d706f7365722d756e757365642f76616c69646174652d706861722e796d6c3f6272616e63683d6d61696e266c6162656c3d6275696c642d70686172267374796c653d666c61742d737175617265)](https://github.com/composer-unused/composer-unused)[![](https://camo.githubusercontent.com/4b77b28478bc9eadcdc35e7e712820dfe7b724768a90162b6ef64fac8d0be60d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672d646174652f636f6d706f7365722d756e757365642f636f6d706f7365722d756e757365642e7376673f6c6162656c3d76657273696f6e267374796c653d666c61742d737175617265)](https://github.com/composer-unused/composer-unused/releases/latest)

Motivation
----------

[](#motivation)

When working in a big repository, you sometimes lose track of your required Composer packages. There may be so many packages you can't be sure if they are actually used or not.

Unfortunately, the `composer why` command only gives you the information about why a package is installed in dependency to another package.

How do we check whether the provided *symbols* of a package are used in our code?

`composer unused` to the rescue!

[![example](art/example.gif)](art/example.gif)

Installation
------------

[](#installation)

⚠️ This tool heavily depends on certain versions of its dependencies. A **local installation of this tool is not recommended** as it might not work as intended or can't be installed correctly. We do recommened you download the `.phar` archive or use **PHIVE** to install it locally.

### PHAR (PHP Archive) (recommended)

[](#phar-php-archive-recommended)

Install via `phive` or grab the latest `composer-unused.phar` from the latest release:

```
phive install composer-unused --trust-gpg-keys DB82D6DEA49B570163338FA33135AA4CB4F1AB0B
curl -OL https://github.com/composer-unused/composer-unused/releases/latest/download/composer-unused.phar

```

### Local

[](#local)

You can also install `composer-unused` as a local **development** dependency:

```
composer require --dev icanhazstring/composer-unused

```

Usage
-----

[](#usage)

Depending on the kind of your installation the command might differ.

*Note: Packages must be installed via `composer install` or `composer update` prior to running `composer-unused`.*

### PHAR

[](#phar)

The `phar` archive can be run directly in you project:

```
php composer-unused.phar

```

### Local

[](#local-1)

Having `composer-unused` as a local dependency you can run it using the shipped binary:

```
vendor/bin/composer-unused

```

### XDebug Performance

[](#xdebug-performance)

For optimal performance, `composer-unused` automatically disables XDebug when it's running to avoid memory overhead and potential compatibility issues.

If you need to debug `composer-unused` itself or run it with XDebug enabled, you can set the `COMPOSER_UNUSED_ALLOW_XDEBUG=1` environment variable:

```
COMPOSER_UNUSED_ALLOW_XDEBUG=1 php composer-unused.phar

```

### Exclude folders and packages

[](#exclude-folders-and-packages)

Sometimes you don't want to scan a certain directory or ignore a Composer package while scanning. In these cases, you can provide the `--excludeDir` or the `--excludePackage` option. These options accept multiple values as shown next:

```
php composer-unused.phar --excludeDir=config --excludePackage=symfony/console
php composer-unused.phar \
    --excludeDir=bin \
    --excludeDir=config \
    --excludePackage=symfony/assets \
    --excludePackage=symfony/console

```

> Make sure the package is named exactly as in your `composer.json`

### Configuration

[](#configuration)

You can configure composer-unused by placing a `composer-unused.php` beside the projects `composer.json`This configuration can look something like this: [composer-unused.php](composer-unused.php)

#### Ignore dependencies by name

[](#ignore-dependencies-by-name)

To ignore dependencies by their name, add the following line to your configuration:

```
$config->addNamedFilter(NamedFilter::fromString('dependency/name'));

```

#### Ignore dependencies by pattern

[](#ignore-dependencies-by-pattern)

To ignore dependencies by pattern, add the following line to your configuration

```
$config->addPatternFilter(PatternFilter::fromString('/dependency\/name/'));

```

> You can ignore multiple dependencies by a single organization using `PatternFilter` e.g. `/symfony\/.*/`

#### Configuration Sets

[](#configuration-sets)

For common framework setups, you can use predefined configuration sets that automatically configure additional scan paths:

```
use ComposerUnused\ComposerUnused\Configuration\ConfigurationSet\SymfonyConfigurationSet;

$composerJson = json_decode(file_get_contents(__DIR__ . '/composer.json'), true);
$rootPackageName = $composerJson['name'] ?? 'root';

$config->applyConfigurationSet(new SymfonyConfigurationSet($rootPackageName));
```

**Available Configuration Sets:**

- **SymfonyConfigurationSet**: Automatically scans `bin/`, `config/`, `public/`, `assets/`, and `migrations/` directories for Symfony projects

See [examples/symfony-composer-unused.php](examples/symfony-composer-unused.php) for a complete example.

#### Creating Custom Configuration Sets

[](#creating-custom-configuration-sets)

You can create your own configuration sets by implementing the `ConfigurationSetInterface`:

```
use ComposerUnused\ComposerUnused\Configuration\Configuration;
use ComposerUnused\ComposerUnused\Configuration\ConfigurationSetInterface;

final class MyFrameworkConfigurationSet implements ConfigurationSetInterface
{
    public function apply(Configuration $configuration): Configuration
    {
        // Add your custom configuration logic here
        return $configuration;
    }

    public function getName(): string
    {
        return 'my-framework';
    }

    public function getDescription(): string
    {
        return 'Custom configuration for My Framework';
    }
}
```

#### Additional files to be parsed

[](#additional-files-to-be-parsed)

Per default, `composer-unused` is using the `composer.json` autoload directive to determine where to look for files to parse. Sometimes dependencies don't have their composer.json correctly set up, or files get loaded in another way. Using this, you can define additional files on a per-dependency basis.

```
$config->setAdditionalFilesFor('dependency/name', []);

```

Changelog
---------

[](#changelog)

Please have a look at [`CHANGELOG.md`](CHANGELOG.md).

Contributing
------------

[](#contributing)

Please have a look at [`CONTRIBUTING.md`](CONTRIBUTING.md).

Code of Conduct
---------------

[](#code-of-conduct)

Please have a look at [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE).

###  Health Score

71

—

ExcellentBetter than 100% of packages

Maintenance84

Actively maintained with recent releases

Popularity70

Solid adoption and visibility

Community48

Growing community involvement

Maturity72

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~51 days

Recently: every ~79 days

Total

50

Last Release

109d ago

PHP version history (6 changes)0.1.0PHP ^7.1

0.6.2PHP &gt;=7.1

0.7.2PHP &gt;=7.3

0.7.6PHP &gt;=7.3 || ^8.0

0.8.0-RC1PHP ^7.4 || ^8.0

0.9.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (173 commits)")[![icanhazstring](https://avatars.githubusercontent.com/u/883543?v=4)](https://github.com/icanhazstring "icanhazstring (121 commits)")[![MarcinGladkowski](https://avatars.githubusercontent.com/u/19622673?v=4)](https://github.com/MarcinGladkowski "MarcinGladkowski (35 commits)")[![bobvandevijver](https://avatars.githubusercontent.com/u/1835343?v=4)](https://github.com/bobvandevijver "bobvandevijver (10 commits)")[![reinfi](https://avatars.githubusercontent.com/u/9324423?v=4)](https://github.com/reinfi "reinfi (9 commits)")[![llaville](https://avatars.githubusercontent.com/u/364342?v=4)](https://github.com/llaville "llaville (9 commits)")[![oliverquynh](https://avatars.githubusercontent.com/u/16967350?v=4)](https://github.com/oliverquynh "oliverquynh (8 commits)")[![Jean85](https://avatars.githubusercontent.com/u/6729988?v=4)](https://github.com/Jean85 "Jean85 (6 commits)")[![pascalheidmann](https://avatars.githubusercontent.com/u/19560252?v=4)](https://github.com/pascalheidmann "pascalheidmann (6 commits)")[![marcelthole](https://avatars.githubusercontent.com/u/850125?v=4)](https://github.com/marcelthole "marcelthole (4 commits)")[![eliashaeussler](https://avatars.githubusercontent.com/u/16313625?v=4)](https://github.com/eliashaeussler "eliashaeussler (4 commits)")[![simPod](https://avatars.githubusercontent.com/u/327717?v=4)](https://github.com/simPod "simPod (4 commits)")[![yoanmLf](https://avatars.githubusercontent.com/u/32323898?v=4)](https://github.com/yoanmLf "yoanmLf (4 commits)")[![OskarStark](https://avatars.githubusercontent.com/u/995707?v=4)](https://github.com/OskarStark "OskarStark (3 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (3 commits)")[![caneco](https://avatars.githubusercontent.com/u/502041?v=4)](https://github.com/caneco "caneco (3 commits)")[![nicklog](https://avatars.githubusercontent.com/u/462920?v=4)](https://github.com/nicklog "nicklog (2 commits)")[![Iandenh](https://avatars.githubusercontent.com/u/2911923?v=4)](https://github.com/Iandenh "Iandenh (2 commits)")[![maxhelias](https://avatars.githubusercontent.com/u/12966574?v=4)](https://github.com/maxhelias "maxhelias (2 commits)")[![mvhirsch](https://avatars.githubusercontent.com/u/573047?v=4)](https://github.com/mvhirsch "mvhirsch (2 commits)")

---

Tags

composerhacktoberfestphpphp-parsercomposerstatic analysisunusedphp-parser

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/icanhazstring-composer-unused/health.svg)

```
[![Health](https://phpackages.com/badges/icanhazstring-composer-unused/health.svg)](https://phpackages.com/packages/icanhazstring-composer-unused)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

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