Brand new to composer. Have it installed and running and have since installed two packages to use on my site by requiring the autoload at the top of the page :
require $_SERVER['DOCUMENT_ROOT'].'/../vendor/autoload.php';
then my use whatever\whatever;
My question is... is there a way I can load single packages rather than everything with the autoload? In this case I am using two packages on the site, but they will never be used together... so... I would think it would make more sense to only load the one(s) I need to use on each page right? There would be a performance difference loading everything with autoload compared to only what I need right?
I've looked around, but can't seem to find an answer to this and if it is possible - maybe I am searching with the wrong terms or looking in the wrong places.
You are already only loading the classes you really need. There is no performance benefit not doing this without the autoloader, but a huge drawback: You will be forced to add every needed class manually if you don't use the autoloader.
You will have a case here if you can prove by measurement that one approach is significantly better than the other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With