Skip to content

Allow skipping vendor-provided PSR4 namespaces for speed

Jason Gill requested to merge jasongill/ClassFinder:master into master

PSR-4 finding is very slow when there are many vendor-provided namespaces; on one of our projects, there are 124 entries in vendor/composer/autoload_psr4.php and running ClassFinder::getClassesInNamespace("..."); takes about 8 seconds to execute.

To make the process faster, this patch allows you to call ClassFinder::disablePSR4Vendors(); which will skip loading all of the PSR-4 classes provided by vendor packages, and instead just stick to the user-defined namespaces from composer.json.

This patch makes our code execute in milliseconds, instead of 8 seconds, and I believe would also help with others who have seen very slow PSR-4 support such as #14

Thanks for this great and very handy project!

Merge request reports