<?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>Sun, 12 Feb 2012 20:25:15 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Charles Sprayberry's Blog: DI and global state]]></title>
      <guid>http://www.phpdeveloper.org/news/17470</guid>
      <link>http://www.phpdeveloper.org/news/17470</link>
      <description><![CDATA[<p>
In response to some of the comments made on his <a href="http://phpdeveloper.org/news/17457">previous post</a> about why you should use dependency injection in your applications, <i>Charles Sprayberry</i> is <a href="http://cspray.github.com/2012/01/29/DI-and-global-state.html">back with some more concrete examples</a> showing how it all works with some code to back it up.
</p>
<blockquote>
To help better explain each of the three aspects of DI I discussed in the previous article I'll be going over each more thoroughly and with those code examples requested. I'll be going through each point one at a time as the explanations will likely be of some length compared to the original post.
</blockquote>
<p>
He starts with the "villain" of the story - the Singleton design pattern, a difficult to test method that lulls you into thinking you're not in the global scope. He talks about the problem of using this approach and how the <a href="http://sourcemaking.com/design_patterns/factory_method">Factory</a> design pattern can be used to create an alternative. He changes up the example to create a "DbTableFactory" class that can be used to create the objects needed - in this case a "UserTable" object with the connection injected into it at construct time.
</p>]]></description>
      <pubDate>Tue, 31 Jan 2012 09:24:47 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Marcelo Gornstein's Blog: Writing PHP applications with Doctrine2 as ORM and Ding as DI container]]></title>
      <guid>http://www.phpdeveloper.org/news/17469</guid>
      <link>http://www.phpdeveloper.org/news/17469</link>
      <description><![CDATA[<p>
In a recent post <i>Marcelo Gornstein</i> takes a look at <a href="http://marcelog.github.com/articles/php_applications_with_doctrine2_orm_and_ding_di_container.html">using dependency injection with Doctrine2</a> using his <a href="http://marcelog.github.com/Ding">Ding</a> container.
</p>
<blockquote>
This article will show how we can develop software in php with a nifty design and architecture, and very much like other languages like java, using an ORM and an AOP, DI, Events container. I will assume you've read (or at least took a quick look) at <a href="http://marcelog.github.com/articles/creating_php_cli_standalone_portable_applications_with_pear_dependencies.html">this article</a> that explains the tree layout used throughout the code, and that you have some basic knowledge of <a href="http://www.doctrine-project.org/">Doctrine2</a> and used it before on your own.
</blockquote>
<p>
He starts with the result - an easy to use, self-contained (and decoupled) system for accessing the Doctrine2 instance. It's event-driven and uses <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect-oriented programming</a> to mange interactions between components (or as he calls them "beans"). Code is included for the entire process for a logger, the User entity, entity manager, user repository and transactional aspect. You can find the complete source for his example <a href="https://github.com/marcelog/Doctrine2-Ding-Example">on his github account</a>.
</p>]]></description>
      <pubDate>Tue, 31 Jan 2012 08:59:18 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Charles Sprayberry's Blog: Why you should use DI]]></title>
      <guid>http://www.phpdeveloper.org/news/17457</guid>
      <link>http://www.phpdeveloper.org/news/17457</link>
      <description><![CDATA[<p>
In <a href="http://cspray.github.com/2012/01/24/why-you-should-use-DI.html">this recent post</a> from <i>Charles Sprayberry</i> he explains why using dependency injection (DI) in your application is a good idea and can help make things easier in the long run.
</p>
<blockquote>
Dependency Injection is just a fancy term for passing dependencies to the object needing them instead of letting the object create its own. Hopefully, you've watched this <a href="http://googledata.org/google-testing/clean-code-talks-dependency-injection/">great Google Clean Code talk about dependency injection</a> by <a href="http://misko.hevery.com/">Misko Hevery</a> where he talks about why you should ask for things instead of looking for them. I'm gonna talk about some reasons to use DI beyond just those presented in the video. 
</blockquote>
<p>He breaks it up into a few different sections:</p>
<ul>
<li>It helps in the battle against global state
<li>It helps your design
<li>It makes using the single responsibility principle easier
</ul>]]></description>
      <pubDate>Fri, 27 Jan 2012 10:18:48 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 12)]]></title>
      <guid>http://www.phpdeveloper.org/news/17445</guid>
      <link>http://www.phpdeveloper.org/news/17445</link>
      <description><![CDATA[<p>
In <a href="http://fabien.potencier.org/article/62/create-your-own-framework-on-top-of-the-symfony2-components-part-12">this final post</a> of his series about building a framework on Symfony2 components, <i>Fabien Potencier</i> focuses again on flexibility - allowing you to have more than one front controller with different configurations thanks to dependency injections.
</p>
<blockquote>
Does it means that we have to make a choice between flexibility, customization, ease of testing and not having to copy and paste the same code into each application front controller? As you might expect, there is a solution. We can solve all these issues and some more by using the Symfony2 dependency injection container.
</blockquote>
<p>
The Symfony2 DIC (DependencyInjection) allows you to create a container with the objects and settings that you want and inject that into the main "Framework" class for its use. He registers most of the components he's added over the series like the UrlMatcher, RouterListener, ExceptionListener, EventDispatcher and the Framework class itself. This is all stored in a separate file(s) and can be conditionally included based on your environment. He shows how to register a custom listener, add parameters to the DIC configuration.
</p>]]></description>
      <pubDate>Wed, 25 Jan 2012 08:36:48 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Michael Nitschinger's Blog: Playing with Composer and Lithium]]></title>
      <guid>http://www.phpdeveloper.org/news/17439</guid>
      <link>http://www.phpdeveloper.org/news/17439</link>
      <description><![CDATA[<p>
<i>Michael Nitschinger</i> has a new post to his blog looking at using the popular <a href="http://packagist.org/about-composer">Composer</a> tool for package management <a href="http://nitschinger.at/Playing-with-Composer-and-Lithium">together with Lithium</a> to make dependency management simpler.
</p>
<blockquote>
<a href="http://packagist.org/about-composer">Composer</a> is a command-line tool that helps you manage your application dependencies. It automatically fetches packages, resolves dependencies and is easy to configure. [...] Currently, Lithium doesn't provide Composer packages out of the box, but it's easy to write one.
</blockquote>
<p>
He starts the post with an introduction to using Composer for those new to the tool, then moves quickly into setting up your "composer.json" file to pull in the Lithium updates from their github account. Additionally, he shows how to add a dependency for <a href="http://twig.sensiolabs.org/">twig</a> in the "require" section and pull it down at the same time (with dependencies).
</p>]]></description>
      <pubDate>Tue, 24 Jan 2012 10:20:51 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Nelm.io Blog: Composer: Part 1 - What & Why]]></title>
      <guid>http://www.phpdeveloper.org/news/17239</guid>
      <link>http://www.phpdeveloper.org/news/17239</link>
      <description><![CDATA[<p>
On the Nelm.io blog today there's a new post (part one of a series) about <a href="http://nelm.io/blog/2011/12/composer-part-1-what-why/">using Composer and Packagist to manage PHP applications</a> as packages.
</p>
<blockquote>
You may have heard about <a href="https://github.com/composer/composer">Composer</a> and <A href="http://packagist.org/">Packagist</a> lately. In short, Composer is a new package manager for PHP libraries. Quite a few people have been complaining about the lack of information, or just seemed confused as to what it was, or why the hell we would do such a thing. This is my attempt at clarifying things.
</blockquote>
<p>
The briefly explains what the tool(s) do and shows how to set up the configuration on both sides - Composer to manage the packages and the package definition configurations (including meta about the project and any dependencies). He also answers several "why" questions about the need for a package manager, using this versus PEAR, the choice of JSON for config definition and a current status of the project.
</p>]]></description>
      <pubDate>Fri, 09 Dec 2011 13:14:34 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Service Layers in PHP Applications (a Series)]]></title>
      <guid>http://www.phpdeveloper.org/news/17004</guid>
      <link>http://www.phpdeveloper.org/news/17004</link>
      <description><![CDATA[<p>
DevShed has posted a series of tutorials talking about different sorts of service layers in PHP applications - seven of them to be exact:
</p>
<blockquote>
If you're looking for an approachable guide that teaches you how to implement an easily-customizable service layer in PHP, then take a peek at this article series. In a step-by-step fashion, it walks you through the development of a sample web application, which uses a service to perform CRUD operations on a domain model composed of a few user entities.
</blockquote>
<p>Service layer types covered in the series are:</p>
<ul>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-A-Final-Example/">Working with database entities</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Services-Layers-Data-Mappers/">Data Mappers</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-Database-Adapters/">Database adapters</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-Handling-Entity-Collections/">Handling Entity Collections</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-User-Services/">User Services</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-Dependency-Injection/">Dependency Injections</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-Modeling-Domain-Objects/">Modeling Domain Objects</a>
</ul>]]></description>
      <pubDate>Tue, 18 Oct 2011 08:50:09 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Padraic Brady's Blog: Zend Framework 2.0: Dependency Injection (Part 1)]]></title>
      <guid>http://www.phpdeveloper.org/news/16953</guid>
      <link>http://www.phpdeveloper.org/news/16953</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Padraic Brady</i> takes a look at <a href="http://blog.astrumfutura.com/2011/10/zend-framework-2-0-dependency-injection-part-1/">dependency injection in Zend Framework 2.0</a>. In this first part, however, he introduces the concept of "dependency injection" and offers a few suggestions on its use and tools that can make it simpler.
</p>
<blockquote>
If you've been watching the PHP weather vane (we call it Twitter for short), you may have noticed a shift in Symfony and Zend Framework. Version 2.0 of both web application frameworks feature Dependency Injection Containers (DICs) as the primary means of creating the objects (and even Controllers) your application will use. This is an interesting shift in a programming language that often stubbornly evaded adopting DICs to any great extent. 
</blockquote>
<p>
He introduces dependency injection (DI) as a method for "injecting" objects and configurations into other interfaces without any specific kind of relation between the two. Part of several DI implementations is a container that does some of the magic object creation for you. He applies this concept to a Zend Framework structure and talks briefly about why these containers are "the devil" because they (usually) add complexity where none is needed. He points out one container library, <a href="http://pimple.sensiolabs.org/">Pimple</a>, that gets it right in his opinion - defining object creation as closures. In the next part of the series, he'll compare the Zend Framework's DI setup against Pimple (and Symfony's) implementations.
</p>]]></description>
      <pubDate>Wed, 05 Oct 2011 12:34:33 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Wojciech Sznapka's Blog: Loosening dependencies with closures in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16911</guid>
      <link>http://www.phpdeveloper.org/news/16911</link>
      <description><![CDATA[<p>
<i>Wojciech Sznapka</i> has a new tutorial posted to his blog today looking at removing some of the issues surrounding dependencies in PHP applications <a href="http://blog.sznapka.pl/loosening-dependencies-with-closures-in-php">with the help of closures</a>.
</p>
<blockquote>
Today I ran into a little issue: how to pass generic logger object to method? I wanted to get some verbose output from method, which I call from Command, but onc time it should log with Symfony2 OutputInterface and other time it should use monolog logger. Of course I can make some wrapper class for both of them, but it would be kind of an overkill. The Closure from PHP 5.3 came with solution.
</blockquote>
<p>
His alternative creates a closure for his Symfony2 application that defines the logger handling in an abstract way and injects that object into his job queue manager for handling. This way the manager doesn't have to worry about handing the mailing itself, it's just deferred to the mailing object. You can find out more about this technique, dependency injection, <a href="http://en.wikipedia.org/wiki/Dependency_injection">here</a>.
</p>]]></description>
      <pubDate>Tue, 27 Sep 2011 08:22:46 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Juozas Kaziukenas' Blog: Dependencies management in PHP projects]]></title>
      <guid>http://www.phpdeveloper.org/news/16845</guid>
      <link>http://www.phpdeveloper.org/news/16845</link>
      <description><![CDATA[<p>
In his latest post to his Web Species blog <i>Juozas Kaziukenas</i> looks at <a href="http://blog.webspecies.co.uk/2011-09-09/dependencies-management-in-php-projects.html">dependency management in PHP applications</a> and offers a few suggestions of how you can make them easier to track.
</p>
<blockquote>
Rarely a project lives by itself, especially in the days of frameworks. Furthermore, there are a lot of great open source libraries you might want to use to save time. But all of this raises a new problem - how could we manage all those dependencies. Here are some thoughts on this problem and how you might want to solve it; without shooting yourself in a foot. 
</blockquote>
<p>
He mentions <a href="http://svnbook.red-bean.com/en/1.0/ch07s03.html">svn:externals</a> and <a href="http://kernel.org/pub/software/scm/git/docs/git-submodule.html">git's submodule</a> as options in version control systems, PEAR for package management, <a href="http://maven.apache.org/">Apache Maven</a> and the <a href="https://github.com/symfony/symfony-standard/blob/master/deps">deps</a> file in the Symfony framework.
</p>]]></description>
      <pubDate>Mon, 12 Sep 2011 10:39:14 -0500</pubDate>
    </item>
  </channel>
</rss>

