1

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.

PajuranCodes
  • 303
  • 3
  • 12
  • 43

1 Answers1

0

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.

Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261
  • Hello, Matthieu, and thank you. I read your answer and the link again. Somehow now I can ask better, if I may?... Let's suppose, the [objects](http://php-di.org/doc/definition-overriding.html#objects) situation will never occur in my code and that only the [arrays](http://php-di.org/doc/definition-overriding.html#arrays) situation, would be of interest. What would happen, if I would first load a .php configuration page containing only the second definition (the one with `DI\add(...)`), and only after that I would load another page containg the first code snippet? – PajuranCodes Apr 22 '19 at 19:42
  • Would the loading order of pages into container matter? And, different from previous comment: what would happen, if a page with a `string({myvar})` reference in it would be loaded before the page containing the definition `myvar` in it? Whould then the loading order matter? Thank you. – PajuranCodes Apr 22 '19 at 19:46