2

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?

Fractaliste
  • 5,777
  • 11
  • 42
  • 86
  • a use case can be found here: http://stackoverflow.com/questions/28701331/how-to-use-pimple-c-extension – ivoba Feb 25 '15 at 11:12

1 Answers1

5

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.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266