@mnapoli opened this Pull Request on October 29th 2014 Member

I've added the DI container. I've kept things simple for now to have a readable diff.

  • require PHP-DI v5.0-dev
  • added an empty config/global.php config file, alongside the existing config files
  • the container will also include a 'config/config.php' file if it exists, this file being in .gitignore (so users can override the global config)
  • added Piwik\StaticContainer, which returns a singleton of the container: this is deprecated already but necessary so that the container can be used in singletons to migrate to DI
  • the FrontController now uses the container to create controllers

That means that we have DI in controllers.

@mattab commented on October 30th 2014 Owner


  • I like the annotation way to inject dependencies, it is lean & readable
  • There are many dependencies in php-di - would be great to remove as many as possible when possible

Excellent to see we're getting started on DI!

@mnapoli commented on October 30th 2014 Member

Regarding the number of dependencies, I had planned to make ocramius/proxy-manager optional in v5.0. I've created an issue for this: https://github.com/mnapoli/PHP-DI/issues/198

I've made the change and created a new 5.0 branch. We will be using that branch in Piwik, that will allow us to make agile changes for v5.0 while not having to rush releasing that new version. I'll keep it as stable and merge features in the branch only when they are considered stable.

For those interested in following v5.0 here is the branch: https://github.com/mnapoli/PHP-DI/pull/200

@mnapoli commented on November 4th 2014 Member

@mattab this PR can be merged to be released in a beta.

The container is used to create all controllers, i.e. new $controllerClass() has been replaced by $container->make($controllerClass).
But nothing is injected anywhere, I've removed the examples using annotations.

That simple change will let us test that everything works correctly for users.

@mattab commented on November 4th 2014 Owner

Excellent! now let's see if beta testers notice any problem or error :+1:

@mattab commented on November 4th 2014 Owner

@diosmosis the day has come that PHP-DI is included in Piwik! REJOICE!

This Pull Request was closed on November 4th 2014
Powered by GitHub Issue Mirror