composer-unused
Show unused packages by scanning your code
Motivation
Working in a big repository with multiple people, sometimes you might lose track of you required composer packages. You have so many packages you can't be sure if they are used or not.
You can use composer why package/A
but that only gives you information about why this package is installed
in dependency to another package.
What if you need to find out if the provided namespaces of the package are used in your code?
composer unused
to the rescue!
Installation
Run
$ composer global require icanhazstring/composer-unused
Usage
Run
$ composer unused
Exclude folders and packages
Sometimes you don't want to scan a certain dir or ignore a composer package while scanning.
For this you can provide the --excludeDir|-xd
or the --excludePackage|-xp
parameter.
$ composer unused --excludeDir=config --excludePackage=symfony/console
Make sure the package is named exactly as in your
composer.json
You can provide multiple folders and package by repeating the argument.
Troubleshooting
If you encounter some errors, try running
$ composer unused -vvv
This will enable debug mode and create an error report beside your composer.json
.
composer-unused-dump-YmdHis
Example (doctrine/orm)
vagrant@ubuntu-bionic:/vagrant/doctrine/orm$ composer unused
Loading packages
----------------
Loading 15 requirements
15/15 [-----------------------------] 100%
! [NOTE] Skipped 2 requirements. No package found or invalid constraint.
* php
* ext-ctype
! [NOTE] Found 13 packages to be checked.
Scanning files...
-----------------
1174/1174 [-----------------------------] 100%
Found 13 used and 0 unused packages
Results
-------
Used packages
* doctrine/annotations ✓
* doctrine/cache ✓
* doctrine/collections ✓
* doctrine/dbal ✓
* doctrine/event-manager ✓
* doctrine/inflector ✓
* doctrine/instantiator ✓
* doctrine/persistence ✓
* doctrine/reflection ✓
* ocramius/package-versions ✓
* ocramius/proxy-manager ✓
* symfony/console ✓
* symfony/var-dumper ✓
Unused packages
Changelog
Please have a look at CHANGELOG.md
.
Contributing
Please have a look at CONTRIBUTING.md
.
Code of Conduct
Please have a look at CODE_OF_CONDUCT.md
.
License
This package is licensed using the MIT License.