<?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>Sat, 18 May 2013 16:46:32 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: Inversion of Control - The Hollywood Principle]]></title>
      <guid>http://www.phpdeveloper.org/news/18865</guid>
      <link>http://www.phpdeveloper.org/news/18865</link>
      <description><![CDATA[<p>
In <a href="http://phpmaster.com/inversion-of-control-the-hollywood-principle/">this new tutorial</a> on PHPMaster.com, <i>Alejandro Gervasio</i> looks at the Inversion of Control methodology and how it's more than just an abstract reference to dependency injection.
</p>
<blockquote>
Traditionally, application components have been designed to operate on and control the execution environment, an approach that delivers well to some extent. [...]  Instead of making the module completely responsible for logging data to multiple endpoints, we can transfer the responsibility straight to the external environment. [...] Not surprisingly, the process of inverting these responsibilities between components and the environment is formally known as Inversion of Control (or in a more relaxed jargon, <a href="http://en.wikipedia.org/wiki/Hollywood_principle">The Hollywood Principle</a>), and its implementation can be a real boost when it comes to developing extensible, highly-decoupled program modules.
</blockquote>
<p>
He uses a set of domain objects (Posts and Comments in a typical blog structure) and the Observer pattern to show how mixed up things might get if the application isn't carefully coded. He takes this and updates it to include a "comment notification service" that implements the SplObserver and is attached to the post to be executed on an event (in this case, the setting of a new comment).
</p>]]></description>
      <pubDate>Mon, 10 Dec 2012 09:43:50 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Reese Wilson: Using the ServiceManager as an Inversion of Control Container (Part 1)]]></title>
      <guid>http://www.phpdeveloper.org/news/18534</guid>
      <link>http://www.phpdeveloper.org/news/18534</link>
      <description><![CDATA[<p>
The <a href="http://zendblog.shinymayhem.com/2012/09/using-servicemanager-as-inversion-of.html">this recent post</a> to his blog <i>Reese Wilson</i> looks at using one of the modules of the Zend Framework v2, the ServiceManager, as an <a href="http://en.wikipedia.org/wiki/Inversion_of_control">inversion of control</a> container in your app.
</p>
<blockquote>
In Zend Framework 1, it was difficult to follow best practices when it came to writing testable code. Sure, you could make testable models, but once you need those models in a controller, what do you do? Zend Framework 2 makes it much easier. In this post, I'll cover the basics of injecting a model into a controller. The main goal here is to be able to wire up and configure your application from the highest level possible. Constructor injection + inversion of control makes it easy to determine which classes are dependent on other classes.
</blockquote>
<p>
He creates a "Building" module and a "BuildingController" inside of it. This controller takes in an instance of a "Building" model as a dependency. He also shows how to define this dependency in the "getControllerConfig" method of your module to make it work automatically. He makes the "Building" model itself with no dependencies and sets it up as an "invokable" in that same "getControllerConfig" method.
</p>]]></description>
      <pubDate>Mon, 01 Oct 2012 08:04:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Christopher Bledsoe's Blog: PHP Dependency Injection (Inversion of Control)]]></title>
      <guid>http://www.phpdeveloper.org/news/15709</guid>
      <link>http://www.phpdeveloper.org/news/15709</link>
      <description><![CDATA[<p>
On his ClickMagnate site <i>Christopher Bledsoe</i> has <a href="http://www.clickmagnate.com/2011/01/04/php-dependency-injection-inversion-of-control/">an interesting post</a> looking at dependency injection (or, as he calls it "inversion of control") in PHP applications.
</p>
<blockquote>
.NET and Java have some great IoC (Inversion of Control) containers but PHP hasn't gotten the same kind of dependency love (I know there are a few people who have tried to tackle this problem but I wanted something that worked with Zend Framework - my framework of choice). I also wanted the dependencies to be defined via the application.ini that Zend Framework uses... So, here's my attempt at that.
</blockquote>
<p>
He includes both the configuration (Zend Framework based) of his dependency injection (DI) class that lists the classes each instance needs to have injected and the code for the actual DI class. The process looks at the configuration file and, if it finds something with the current class name, creates an instance of the class to inject and push it into the controller.
</p>
]]></description>
      <pubDate>Mon, 10 Jan 2011 09:39:03 -0600</pubDate>
    </item>
  </channel>
</rss>
