php-di

PHP-DI: Does in any way matter, in which order the definition files are loaded into the container?


I plan to have many definitions files (e.g. configuration files), in separate directories and multiple-level subdirectories. Let's suppose, that these files will contain many complex definition situations - so to say.

So I would like to ask: Does IN ANY WAY matter, in which order the definitions files are loaded into the container?

Note: The definitions found in configuration files corresponding to a certain application environment (like 'prod', 'dev', etc) will always override the "normal" definitions. So, this should not be of relevance for an eventual answer.

Thank you.


Solution

  • Yes the order matters as this constitutes the basis for the "module" system in PHP-DI.

    See http://php-di.org/doc/definition-overriding.html to understand how definitions can extend and override each others.