You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
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)
Install via phive or grab the latest composer-unused.phar from the latest release:
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
The phar archive can be run directly in you project:
php composer-unused.phar
Local
Having composer-unused as a local dependency you can run it using the shipped binary:
vendor/bin/composer-unused
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:
Make sure the package is named exactly as in your composer.json
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
Ignore dependencies by name
To ignore dependencies by their name, add the following line to your configuration:
You can ignore multiple dependencies by a single organization using PatternFilter e.g. /symfony\/.*/
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.