Search code examples
symfonydependencieslibrariesyarnpkg

How to check if libraries are unused in Symfony?


I have a lot of libraries listed in my package.json and I know that most of them are unused. How could I know the ones I use and the other one I do not use ?

I am using Symfony 3.4 and Yarn as Dependency Manager

Thanks !


Solution

  • If you want to know why a packages is installed, you can run the command why. As example, see this list:

    >composer show
    doctrine/instantiator             1.0.5   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
    phpdocumentor/reflection-common   1.0.1   Common reflection classes used by 
    .....
    input/output with nice error messages.
    

    See the instantiator package

    >composer why doctrine/instantiator
    phpspec/prophecy              1.8.0  requires  doctrine/instantiator (^1.0.2)
    phpunit/phpunit-mock-objects  2.3.8  requires  doctrine/instantiator (^1.0.2)
    

    You can also try the tree version:

    >composer why -t doctrine/instantiator
    doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
    ├──phpspec/prophecy 1.8.0 (requires doctrine/instantiator ^1.0.2)
    │  └──phpunit/phpunit 4.8.36 (requires phpspec/prophecy ^1.3.1)
    │     └──XXXXXXXX dev-master (requires (for development) phpunit/phpunit ~4.6)
    └──phpunit/phpunit-mock-objects 2.3.8 (requires doctrine/instantiator ^1.0.2)
       └──phpunit/phpunit 4.8.36 (requires phpunit/phpunit-mock-objects ~2.3)
          └──XXXXXXXX dev-master (requires (for development) phpunit/phpunit ~4.6)