PHP-DI / Slim-Bridge

PHP-DI integration with the Slim framework
http://php-di.org/doc/frameworks/slim.html
MIT License
176 stars 38 forks source link

Decoupling the App constructor from the ContainerBuilder #43

Closed adriansuter closed 5 years ago

adriansuter commented 5 years ago

Hi there

How about injecting the ContainerBuilder as a parameter to the App constructor?

https://github.com/PHP-DI/Slim-Bridge/blob/df3c116bedb325c88c01991605380b0fd77b97ed/src/App.php#L17

I mean, there are some properties in the ContainerBuilder (for example the containerClass), which can't be overwritten in the configureContainer method. To make it backwards-compatible I would suggest to pass null by default and to let the constructor instantiate the ContainerBuilder if the parameter is null.

mnapoli commented 5 years ago

Hi, the App class is 5 lines of actual PHP code. If you have more advanced needs like this I encourage you to do this (this is what I do): create your container manually and use the Slim\App class directly.