Dependency injection in PHP5

Dependency injection in PHP5

0 117

PHP Thinktank Blog have a very good article which point to the Dependency injection technique with PHP5. The dependency injection pattern is very common in the java world, what is called also the Inversion of Control Containers. The techniques that Tomas have implemented in Garden is very similar to the Spring framework, which would use XML definitions with syntax as similar as possible. Very interesting pattern for those working on large scale, and trust that PHP applications can be scalable, easily maintainable and designed well.

Several months ago I started using Spring Framework. That is how I faced the dependency injection. As my programming skills mostly originated from web development with PHP, I found out that I’ve missed a great technique, which is as usually common in Java land, but rare in PHP. I ended up with a research of dependency injection libraries for PHP. There was a port of Pico container by Pawel Kozlowski, who gave a talk on it recently, and that was almost it (some bright minds from #php.thinktank had their own solutions for that).