This question already has an answer here:
When I use use Class\Whatever
or include 'Class/Whatever'
(or require etc) at the top of a file before the file's Class is declared, does that file load the included file into memory at the time, or is it only loaded in and parsed when it needs to be (lazy-loading)?
I'm not finding any resource that mentions how this behaves or if it's optimized; I'd rather call the use
or include
when they're needed (inside the class when I want to instantiate the included class' object), but if the minimum necessary is already being done with this, then I'll keep them at the top of the file.
Tried moving the calls around but I'm not seeing any way to tell when they actually load or are compiled and parsed.
require 'baseClasses/Controller.php';
require 'vendor/autoload.php'; // Autoload.php is generated by Composer
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Hmac\Sha256;
Expected results are for the PHP engine to simply mark a use/include for loading and parsing when a line of code actually tries to do something with it. I can't tell what the actual results are other than my code just works, but I don't want unnecessary resources loading and parsing when they're not actually being used.
</div>