<?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 13:50:39 -0500</pubDate>
    <ttl>30</ttl>
    <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[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[Gonzalo Ayuso: How to configure Symfony's Service Container to use Twitter API]]></title>
      <guid>http://www.phpdeveloper.org/news/19136</guid>
      <link>http://www.phpdeveloper.org/news/19136</link>
      <description><![CDATA[<p>
In <a href="http://gonzalo123.com/2013/02/04/how-to-configure-symfonys-service-container-to-use-twitter-api/">this recent post</a> to his site <i>Gonzalo Ayuso</i> shows how to use the Symfony2 service container to interact directly with the Twitter API via an OAuth plugin.
</p>
<blockquote>
If we are working within a Symfony2 application or a PHP application that uses the Symfony's Dependency injection container component you can easily integrate this simple script in the service container. I will show you the way that I use to do it. 
</blockquote>
<p>
His sample code uses the <a href="http://guzzlephp.org/">Guzzle</a> HTTP library and some configuration options from a YAML file to create a new service hooked into the Twitter API with his credentials. He then imports it via his services configuration and shows an example of it in action - getting the latest contents of his timeline.
</p>]]></description>
      <pubDate>Tue, 05 Feb 2013 10:53:19 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Ralph Schindler: DI, DiC, & Service Locator Redux]]></title>
      <guid>http://www.phpdeveloper.org/news/18591</guid>
      <link>http://www.phpdeveloper.org/news/18591</link>
      <description><![CDATA[<p>
In his latest post <i>Ralph Schindler</i> takes another look at <a href="http://ralphschindler.com/2012/10/10/di-dic-service-locator-redux">the usefulness of Dependency Injection Containers</a> and whether or not they're the right thing to use for your situation.
</p>
<blockquote>
To DiC, or not to DiC: that has seemed to be the question in PHP for the last few years. Most people generally agree that injecting dependencies is the right thing to do. For those writing a framework, or any shared codebase where extensibility or the ability to grow the codebase is a core philosophical tenet, not injecting dependencies is doing a disservice to the project in the long run. So, as I've stated before, the question becomes how do we manage the added complexity that comes with practicing dependency injection?
</blockquote>
<p>
He briefly covers two topics that are often confused - the concepts of a service locator and a true dependency injection container. He then talks about the more correct situations to use each of them, mentioning a few questions you can ask about your app to determine the best fit. To illustrate, he includes a simple example where he mixed the two - DIC for models and service location for the controllers. 
</p>]]></description>
      <pubDate>Thu, 11 Oct 2012 10:43:38 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Juan Treminio: An introduction to Pimple and Service Containers]]></title>
      <guid>http://www.phpdeveloper.org/news/18563</guid>
      <link>http://www.phpdeveloper.org/news/18563</link>
      <description><![CDATA[<p>
<i>Juan Treminio</i> has a new post to his site introducing the ideas behind <a href="http://jtreminio.com/2012/10/an-introduction-to-pimple-and-service-containers/">Pimple and service containers</a>, two very similar approaches to dependency management in your applications.
</p>
<blockquote>
Recently I've picked up the Silex framework for a project I'm building. It uses a service container for managing dependencies in your application [<a href="https://github.com/fabpot/Pimple">Pimple</a>], which is great for defining (not instantiating) objects and their default behaviors in a single location, rather than sprinkled throughout your code in a multitude of places. [...] Using Pimple you can define several hundreds of objects, and then easily instantiate them using the container object.
</blockquote>
<p>
He goes through some example code showing how to use Pimple to create and manage the dependencies by creating several instances of DateTime objects. He shows how this can then be "upgraded" to a service container by defining something like a PDO object (database connection) inside it. He also mentions some of the benefits that come with its use - easy resource swapping, simpler mocking for testing and allows the use of the Inversion of Control pattern.
</p>]]></description>
      <pubDate>Fri, 05 Oct 2012 11:18:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Patrick van Kouteren: CloudVPS object store beta introduction]]></title>
      <guid>http://www.phpdeveloper.org/news/18414</guid>
      <link>http://www.phpdeveloper.org/news/18414</link>
      <description><![CDATA[<p>
<i>Patrick van Kouteren</i> has <a href="http://www.vankouteren.eu/blog/2012/08/cloudvps-object-store-beta-introduction/">a new tutorial posted</a> to his site showing you how to connect your application with an OpenStack instance (specifically the <a href="https://www.cloudvps.com/community/knowledge-base/cloudvps-object-store/">CloudVPS</a> option) via some simple CURL commands (easily translatable <a href="http://php.net/curl">into PHP</a>).
</p> 
<blockquote>
Lately I've been playing around with the <a href="https://www.cloudvps.com/community/knowledge-base/cloudvps-object-store/">CloudVPS ObjectStore</a>, which is currently in beta phase. This blogpost shows the options of this ObjectStore in a practical way and concludes with a summary of commands you can use yourself to interact with it and some ideas. For this post, I assume you are familiar with cURL, REST and HTTP headers.
</blockquote>
<p>He shows how to make the requests for:</p>
<ul>
<li>Authentication
<li>Working with containers
<li>Adding files to a container
<li>Setting access permissions
</ul>]]></description>
      <pubDate>Tue, 28 Aug 2012 12:52:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Anthony Ferrara: Object Scoping: A Triste Against Service Containers]]></title>
      <guid>http://www.phpdeveloper.org/news/18394</guid>
      <link>http://www.phpdeveloper.org/news/18394</link>
      <description><![CDATA[<p>
In <a href="http://blog.ircmaxell.com/2012/08/object-scoping-triste-against-service.html">his most recent post</a> <i>Anthony Ferrara</i> talks about service containers, the cousin of dependency injection containers (DIC) that he argues aren't much better than global variables.
</p>
<blockquote>
I am a firm believer that service containers are not a form of Dependency Injection, and are only slightly better than global variables. That led me to make a <a href="https://twitter.com/ircmaxell/status/237957185974435840">few comments</a> that elicited a reply from two Fuel developers. That led to a rather interesting debate that just couldn't fit into 140 characters [on Twitter]... So I'm going to go into topics that are tightly related: variable scoping and service locators.
</blockquote>
<p>
He starts by defining what global variables are (including the requisite <a href="http://en.wikipedia.org/wiki/Global_variable">Wikipedia definition</a>) and how they're commonly use "everywhere" in the application, both set and read from. He contrasts this idea against a static variable from a class and redefines the scoping a bit when talking about objects and their properties. 
</p>
<blockquote>
So how does this apply to service locators (aka service containers or dependency injection containers)? Well, all state that's managed by a service locator immediately becomes global state to the objects that use the locator. So why is it all the rage? It's simple. It seems simple on the surface. If your object needs another dependency, there's no need to adjust how it's constructed, just pull it from the locator. Sounds great, right? Well, not quite.
</blockquote>
<p>
He points out some of the main issues with using service locators namely difficulty in unit testing them, dependencies within the container, how it violates both the <a href="http://en.wikipedia.org/wiki/Law_of_Demeter">Law of Demeter</a> and the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Single Responsibility Principle</a> as well as causing "hidden coupling" issues.
</p>]]></description>
      <pubDate>Thu, 23 Aug 2012 08:41:17 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jeune Asuncion: ZF1.11 + Doctrine 2 + Symfony DI Integration]]></title>
      <guid>http://www.phpdeveloper.org/news/18391</guid>
      <link>http://www.phpdeveloper.org/news/18391</link>
      <description><![CDATA[<p>
In <a href="http://jeunito.me/zf1-11-doctrine-2-symfony-di-integration/">this new post</a> to his site <i>Jeune Asuncion</i> shows how he integrated several technologies to make for a robust system - Zend Framework (1.11), Doctrine 2 and the Symfony dependency injection system.
</p>
<blockquote>
Last week, <a href="http://jeunito.me/choosing-a-new-framework/">I blogged about looking for a new application framework</a> to use and more importantly the key things that I would want in one. After reading about the <a href="http://framework.zend.com/">Zend framework</a>, <a href="http://jeunito.me/zf1-11-doctrine-2-symfony-di-integration/www.symfony-project.org/">Symfony</a> and <a href="http://jeunito.me/zf1-11-doctrine-2-symfony-di-integration/laravel.com/">Laravel</a> and finding myself hesitant to use any one, I thought to myself why not get the best of each framework? So that's what I did.
</blockquote>
<p>
He shows a bit of the code to get them to all play nicely together using the Zend autoloader to register the other namespaces and creating a Symfony DI container inside of the ZF Bootstrap and providing it as a resource. You can find more of the source involved in the integration <a href="https://github.com/jeunito/zf-doctrine2-symfonydi">on his github account</a>.
</p>]]></description>
      <pubDate>Wed, 22 Aug 2012 11:09:21 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Joshua Thijssen's Blog: Symfony2: Implementing ACL rules in your Data Fixtures]]></title>
      <guid>http://www.phpdeveloper.org/news/18175</guid>
      <link>http://www.phpdeveloper.org/news/18175</link>
      <description><![CDATA[<p>
<i>Joshua Thijssen</i> has a new post to his blog looking at a method for <a href="http://www.adayinthelifeof.nl/2012/07/04/symfony2-implementing-acl-rules-in-your-data-fixtures/">setting up ACL rules in fixtures</a> for your Symfony2-based applications.
</p>
<blockquote>
Doctrine's DataFixtures are a great way to add test data to your application. It's fairly easy to get this going: Create a fixureLoader that extends DoctrineCommonDataFixturesAbstractFixture, had a load() method and off you go. However, sometimes you want your data also to be protected by Symfony 2&#8242;s ACL layer. Since there isn't a common way to do this, here is one way on how I implemented this.
</blockquote>
<p>
His method uses the ContainerAware interface on the fixture loader instance to be able to get at the container for the fixture. This allows you to use the usual ACL handling methods of the framework to provide restrictions based on things like usernames and roles.
</p>]]></description>
      <pubDate>Wed, 04 Jul 2012 16:33:23 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Luis Atencio's Blog: Dependency Injection in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/18070</guid>
      <link>http://www.phpdeveloper.org/news/18070</link>
      <description><![CDATA[<p>
On his Reflective Thought blog <i>Luis Atencio</i> takes a look at the current state of <a href="http://www.reflectivethought.net/2012/05/dependency-injection-in-php.html">dependency injection in PHP</a> and shares a simple refactor from non-DI to code that uses it as a service locator.
</p>
<blockquote>
If you have worked with frameworks such as Spring or Google Guice, you will understand the power and flexibility that dependency injection provides your humongous code base. [...] One quick drawback that I see is that the stateless nature of PHP makes things like object containers not very practical.
</blockquote>
<p>
He proposes a slightly different kind of dependency injection system, one more akin to what's provided in the Java world where annotation and reflection are components of the integration. He provides a code sample of how this would look and points to Java's JSR-330 standard for some of the annotation examples (like "@inject" or "@scope").
</p>]]></description>
      <pubDate>Sat, 09 Jun 2012 10:55:36 -0500</pubDate>
    </item>
  </channel>
</rss>
