<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Wed, 19 Jun 2013 18:57:20 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Reddit.com: Dependency injection in ZF2 and Symfony 2 are service locators]]></title>
      <guid>http://www.phpdeveloper.org/news/19468</guid>
      <link>http://www.phpdeveloper.org/news/19468</link>
      <description><![CDATA[<p>
On Reddit's PHP section there's a discussion happening about <a href="http://www.reddit.com/r/PHP/comments/1caidn/dependency_injection_in_zf2_and_symfony_2_are/"> dependency injection versus service locators</a> in two popular PHP frameworks - Zend Framework 2 and Symfony 2 (and how they're not really DI at all).
</p>
<blockquote>
Both ZF2 and Symfony 2 offer the same behavior: if I'm in a controller, and I want to use a service, I have to get it from the container with $this->get('my_service').
As such, the controller is not using DI, this is the service locator pattern. Controllers become more difficult to tests because of that, and they depend on the container now. I wonder why both frameworks didn't go further: why not treat controllers like services and use dependency injection on them. In other words: if a controller needs a service "A", then it should get it in the constructor, or through setter/property injection.
</blockquote>
<p>
The <a href="http://www.reddit.com/r/PHP/comments/1caidn/dependency_injection_in_zf2_and_symfony_2_are/">comments</a> talk some about the "controller from the DI container" idea, some other ways around the problem and some clarification as to what the frameworks are actually doing related to the container injection.
</p>
Link: http://www.reddit.com/r/PHP/comments/1caidn/dependency_injection_in_zf2_and_symfony_2_are]]></description>
      <pubDate>Tue, 16 Apr 2013 12:40:07 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: Use Dice for Simplified PHP Dependency Injection]]></title>
      <guid>http://www.phpdeveloper.org/news/19428</guid>
      <link>http://www.phpdeveloper.org/news/19428</link>
      <description><![CDATA[<p>
On PHPBuilder.com there's a new tutorial showing how to <a href="http://www.phpbuilder.com/articles/application-architecture/design/use-dice-for-simplified-php-dependency-injection.html">use the Dice dependency injection container</a> to manage dependencies in your application.
</p>
<blockquote>
<a href="http://r.je/dice.html">Dice</a> is a Dependency Injection Container for PHP. It allows you to very quickly and simply use <a href="http://www.phpbuilder.com/columns/php-dependency-injection/Jason_Gilmore04292011.php3">Dependency Injection</a> techniques in your code with very minimal effort on your end. 
</blockquote>
<p>
The article talks some about the features of the Dice DIC and shares a simple introduction to its use in a more practical example. It uses constructor injection and type hinting to automatically handle the injections based on its current set of object references. 
</p>
<blockquote>
With Dice you don't have to worry about how the User accesses the Session object, you add it as a constructor parameter and it Just works. You don't need to reconfigure the container, you don't need to do anything at all. You just alter the constructor definition and everything is done for you.
</blockquote>
<p>
You can find more details about Dice in <a href="http://r.je/dice.html">this post</a> (including more examples of it in action and a link to it's repository <a href="https://github.com/TomBZombie/Dice">on github</a>.
</p>
Link: http://www.phpbuilder.com/articles/application-architecture/design/use-dice-for-simplified-php-dependency-injection.html]]></description>
      <pubDate>Mon, 08 Apr 2013 13:04:46 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Igor Wiedler: Stateless Services]]></title>
      <guid>http://www.phpdeveloper.org/news/19410</guid>
      <link>http://www.phpdeveloper.org/news/19410</link>
      <description><![CDATA[<p>
<i>Igor Wiedler</i> has a recent post to his site about creating <a href="https://igor.io/2013/03/31/stateless-services.html">stateless services</a>, specifically in the context of using a dependency injection container to manage the objects your application uses.
</p>
<blockquote>
As more frameworks and libraries, particularly in the PHP world, move towards adopting the Dependency Injection pattern they are all faced with the problem of bootstrapping their application and constructing the object graph. In many cases this is solved by a Dependency Injection Container (DIC). Such a container manages the creation of all the things. The things it manages are services. Or are they?
</blockquote>
<p>
He notes that, according to some of the principles of domain-driven design, "services" should be stateless - the results of calls to the service shouldn't alter it, it should only depend on the values passed in. He goes on to put this into the context of a DIC and gives an example of the "request service" (and how it violates the DDD principles of statelessness). He talks some about scopes (dependencies) and mutable services. He talks about methods to get around these issues with the "request" instance, ultimately coming to the conclusion that event listeners might be the way to go.
</p>
Link: https://igor.io/2013/03/31/stateless-services.html]]></description>
      <pubDate>Thu, 04 Apr 2013 10:41:50 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Matt Frost: Dependency Injection Container Question]]></title>
      <guid>http://www.phpdeveloper.org/news/19192</guid>
      <link>http://www.phpdeveloper.org/news/19192</link>
      <description><![CDATA[<p>
In his <a href="http://shortwhitebaldguy.com/blog/2013/02/dependency-injection-container-question">latest post</a> <i>Matt Frost</i> takes a look at dependency injection. He thinks out loud about some of the common uses for it but wonders if there's a middle ground for using a DIC and injecting manual dependencies.
</p>
<blockquote>
The question I have is what if a dependency in one class also has a dependency? To illustrate what I mean, here's an example with some code to follow. [...] I'm not really concerned about the code here as much as I am about the concept that I'm trying to illustrate, in order to use a dependency injection container for this scenario.
</blockquote>
<p>
In his example code, he shows a "DBAuthMethod" class that extends the "AuthMethod" interface and an "Auth" class that requires an instance of "AuthMethod" as a constructor parameter. He wonders about constructor versus setter injection and thinks that a mix of the two may not be the best structure for the code. 
</p>
<blockquote>
I just can wrap my mind around a scenario where you could ONLY use a DIC, and if you can't use the concept exclusively what benefit is there to using it?
</blockquote>
<p>
Have any suggestions to share? <a href="http://shortwhitebaldguy.com/blog/2013/02/dependency-injection-container-question">Let him know</a> - this is a problem more and more developers run into as DIC becomes more widely used.
</p>]]></description>
      <pubDate>Mon, 18 Feb 2013 09:26:17 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Dependency Injection with Pimple]]></title>
      <guid>http://www.phpdeveloper.org/news/19103</guid>
      <link>http://www.phpdeveloper.org/news/19103</link>
      <description><![CDATA[<p>
On PHPMaster.com there's a new tutorial showing you <a href="http://phpmaster.com/dependency-injection-with-pimple/">how to use Pimple</a> (the <a href="http://pimple.sensiolabs.org/">dependency injection container</a> from the Symfony folks) in your application to manage objects and resources.
</p>
<blockquote>
In application development, we try to create independent modules so that we can reuse code in future projects. But, it's difficult to create completely independent modules which provide useful functionality; their dependencies can cause maintenance nightmares unless they are managed properly. This is where Dependency Injection comes in handy, as it gives us the ability to inject the dependencies our code needs to function properly without hard coding them into the modules.
</blockquote>
<p>
They start with a look at the problem with working with "concerete dependencies", ones that are hard-coded into your classes making them not only hard to test but potentially difficult to maintain. They include an example of this (a "SocialFeeds" class and friends) and then one of two ways to fix the situation. They start with using constructor-based injection, injecting the Twitter service into the main feeds object. They also talk about another method - setter-based injection - where the objects are injected via specific methods on the object. 
</p>
<p>
As a third alternative, though, they get to using Pimple to manage the objects, making it easier to inject just the one resource into your classes and extract the objects you need from there. There's also a bit of "advanced" usage of Pimple showing the use of the "share" and "extend" methods.
</p>]]></description>
      <pubDate>Tue, 29 Jan 2013 09:37:50 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso: Handling several DBALs in Symfony2 through the Dependency Injection with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19044</guid>
      <link>http://www.phpdeveloper.org/news/19044</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has a second post in his series looking at using the Symfony2 dependency injection container with Doctrine functionality. In his <a href="http://phpdeveloper.org/news/19007">previous post</a> he talked about sharing PDO connections via the DIC. In <a href="http://gonzalo123.com/2013/01/14/handling-several-dbal-database-connections-in-symfony2-through-the-dependency-injection-container-with-php/">this latest one</a> it's focused on the sharing of DBALs from Doctrine.
</p>
<blockquote>
OK. We can handle PDOs connections inside a Symfony2 application, but what happens if we prefer DBAL. As we know DBAL is built over PDO and adds a set of "extra" features to our database connection. It's something like PDO with steroids.
</blockquote>
<p>
He includes the (PHP) configuration to set up the DBAL and the YAML definition to set it up in the DIC's configuration. As an update to the post, he also points out a bundle for Symfony2 that lets Doctrine do this natively - check out <a href="https://github.com/doctrine/DoctrineBundle/blob/master/Resources/doc/configuration.rst#doctrine-dbal-configuration">this documentation</a> on github.
</p>]]></description>
      <pubDate>Wed, 16 Jan 2013 10:47:32 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Anthony Ferrara: Programming With Anthony - Dependency Injection]]></title>
      <guid>http://www.phpdeveloper.org/news/19018</guid>
      <link>http://www.phpdeveloper.org/news/19018</link>
      <description><![CDATA[<p>
<i>Anthony Ferrara</i> has posted his <a href="http://blog.ircmaxell.com/2013/01/dependency-injection-programming-with.html">latest video tutorial</a> in <a href="https://www.youtube.com/playlist?list=PLM-218uGSX3DQ3KsB5NJnuOqPqc5CW2kW&feature=view_all">his series</a>, this time covering dependency injection (mostly the concepts, not the implementation).
</p>
<blockquote>
This week, we're going to talk about the topic of Dependency Injection in Object oriented code (specifically PHP). You don't need a fancy container to do it, it's actually quite simple to do manually! 
</blockquote>
<p>
He also talks some about the difference between a dependency injection container and a service locator. This is just the latest in his video series - he has others covering things like <a href="https://www.youtube.com/watch?v=nLinqtCfhKY">prepared statements</a>, <a href="https://www.youtube.com/watch?v=RLmuFlDygn0">encryption</a> and <a href="https://www.youtube.com/watch?v=_YZIBWQr_yk">references in PHP</a>.
</p>]]></description>
      <pubDate>Thu, 10 Jan 2013 09:08:57 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[MaltBlue.com: Zend Framework 2 Core Concepts - Dependency Injection]]></title>
      <guid>http://www.phpdeveloper.org/news/18902</guid>
      <link>http://www.phpdeveloper.org/news/18902</link>
      <description><![CDATA[<p>
In <a href="http://www.maltblue.com/articles-2/zend-framework-2-core-concepts-understanding-dependency-injection">this new post</a> <i>Matthew Setter</i> has posted about one of the core concepts behind the structure and use of Zend Framework 2, its use of dependency injection to handy object relationships and access (via Zend/Di).
</p>
<blockquote>
As Zend Framework 2 is well and truly here, before some of us who are new to it dive right on in, whether you're completely new or, like me, migrating from Zend Framework 1, it's really important to ensure that we understand the core concepts on which it's based. [...] In this, the first part in the series, I'm going to go through what dependency injection (DI) is. However, as there are a number of great posts already available on the topic by some very experienced developers, [...] I'm not going to rehash them.
</blockquote>
<p>
Instead he extracts out useful tips from posts of a few other sources on ZF2 and dependency injection in general: <a href="http://mwop.net/blog/260-Dependency-Injection-An-analogy.html">Matthew Weier O'Phinny</a>, the <a href="http://framework.zend.com/manual/2.0/en/modules/zend.di.introduction.html">ZF2 manual</a>, <i>Martin Fowler</i> on <a href="http://martinfowler.com/articles/injection.html"> dependency injection</a>, <a href="http://en.wikipedia.org/wiki/Dependency_injection">Wikipedia</a> and more. He also includes lots of links to more great articles on the subject, both ZF2-specific and for DI iin general.
</p>]]></description>
      <pubDate>Mon, 17 Dec 2012 10:09:53 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[NetTuts.com: Dependency Injection in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/18845</guid>
      <link>http://www.phpdeveloper.org/news/18845</link>
      <description><![CDATA[<p>
If you've wondered what this "dependency injection" term is that's been floating around the PHP community for a bit now is all about, you should check out <a href="http://net.tutsplus.com/tutorials/php/dependency-injection-in-php/">this new tutorial</a> on NetTuts.com today. It's a an introduction to the term/functionality and its use in PHP.
</p>
<blockquote>
Dependency injection has been a frequent subject of discussion among many corporate developers in the past few years. Many feared that they might sacrifice too much time building their application architecture without doing any real work. In this article, I'll explain why PHP developers should consider taking advantage of dependency injection, when building large, scalable projects.
</blockquote>
<p>
They start off with the "what" if dependency injection, showing the refactoring of two classes using the "controller injection" method of dependency management. There's also some mention of its ability to help clean up a code base, some of the DI tools that are out there (like <a href="http://pimple.sensiolabs.org/">Pimple</a>) and some good cases of when to use DI in your app.
</p>]]></description>
      <pubDate>Wed, 05 Dec 2012 09:29:38 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Josh Adell: Migrating to Dependency Injection]]></title>
      <guid>http://www.phpdeveloper.org/news/18794</guid>
      <link>http://www.phpdeveloper.org/news/18794</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Josh Adell</i> talks about his voyage to <a href="http://blog.everymansoftware.com/2012/11/migrating-to-dependency-injection.html">implement dependency injection</a> into a current application. His work can be found in <a href="http://github.com/jadell/laldi">this github repository</a>.
</p>
<blockquote>
Recently, I gave a lunch-and-learn to my team on the topic of Dependency Injection (DI). Instead of showing a bunch of slides explaining what DI is and what it's good for, I created a small project and demonstrated the process of migrating a codebase that does not use DI to one that does. Each stage of the project is a different tag in the repository. The code can be found on Github: <a href="http://github.com/jadell/laldi">http://github.com/jadell/laldi</a>. Checkout the code, and run composer install. To see the code at each step in the process, run the git checkout command in the header of each section.
</blockquote>
<p>
He goes through each "checkout" step (the title is the git command to run to follow along) showing how he migrated away from a simple micro-framework based site to one that defines the various objects (and repositories) inside the "application" object. He adds in a few comments to let you know a bit more about what's going on and some basic event handling. He finishes off the post with some potential issues that could come up both during the process and with the resulting application.
</p>]]></description>
      <pubDate>Fri, 23 Nov 2012 11:41:41 -0600</pubDate>
    </item>
  </channel>
</rss>
