symfonyrefactoringphpstormsilex

How can I find unused libraries in a Symfony project with PhpStorm?


I try to find and also to delete all the unused libraries in a project. For example I have a folder lib/ with lot of other folder which are the famous libraries. I want to know how I can identify which libraries are not used.

I asked the same question here but the only response I received suggests to me to check each file one by one ...

Can you help me?


Solution

  • I don't think that is possible, as some libraries may be lazy loaded depending on some internal state of your application.

    So even if you could somehow find all strong typed references inspecting the code, you have no way of finding out if a library is loaded via magic methods, custom class loaders, dynamically generated include or require statement, eval-ed code and so on.

    Without having tests with 95%+ coverage for your non-library code, it is very risky to remove anything from your lib folder. You code may appear to run fine, but still fail in some edge cases.