46057

I use composer
to manage my dependencies and class loading. This tool uses spl_autoload_register
function.
I would like to use a PHP's extension that provides some classes with same definition (name, namespacing, functionnalities) than others classes defined throught composer.
Which class will PHP load? The extension's one, or the autoload's one, or maybe the PHP's comportment is undefined?
Answer1:
PHP will use the extension's one. This is because autoloading will only happen if you are attempting to access a class which does not already exist. Extension functions and classes will exist after PHP's startup meaning before the code starts to run.