<?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, 25 May 2013 21:51:17 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Rob Allen: Simple logging of ZF2 exceptions]]></title>
      <guid>http://www.phpdeveloper.org/news/19507</guid>
      <link>http://www.phpdeveloper.org/news/19507</link>
      <description><![CDATA[<p>
In <a href="http://akrabat.com/zend-framework-2/simple-logging-of-zf2-exceptions/">this new post to his site</a> <i>Rob Allen</i> shows you how to implement a simple logging method for catching exceptions in your Zend Framework 2 application.
</p>
<blockquote>
I recently had a problem with a ZF2 based website where users were reporting seeing the error page displayed, but I couldn't reproduce in testing. To find this problem I decided to log every exception to a file so I could then go back and work out what was happening. In a standard ZF2 application, the easiest way to do this is to add a listener to the 'dispatch.error' event and log using ZendLog.
</blockquote>
<p>
He uses an event listener to attach a service that contains a "logException" method. This method uses the ZendLog component to write out the error message to a local log file including a backtrace of where the issue occurred.
</p>
Link: http://akrabat.com/zend-framework-2/simple-logging-of-zf2-exceptions]]></description>
      <pubDate>Thu, 25 Apr 2013 10:31:40 -0500</pubDate>
    </item>
    <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[Rob Allen: Objects in the model layer: Part 2]]></title>
      <guid>http://www.phpdeveloper.org/news/19398</guid>
      <link>http://www.phpdeveloper.org/news/19398</link>
      <description><![CDATA[<p>
<i>Rob Allen</i> <a href="http://akrabat.com/development/objects-in-the-model-layer/">previously posted</a> about some of his practices around the different types of objects in the model layer of his Zend Framework 2 applications. In <a href="http://akrabat.com/php/objects-in-the-model-layer-part-2/">this latest post</a> he follows up and shares some example code for the different types.
</p>
<blockquote>
I previously talked about the terms I use for <a href="http://akrabat.com/development/objects-in-the-model-layer/">objects in the model layer</a> and now it's time to put some code on those bones. Note that,as always, all code here is example code and not production-ready.
</blockquote>
<p>
He includes sample classes related to his "books" examples - a "book" entity (with title, author, id and ISBN), a mapper object to load/save/delete the entity and a service object that provides an interface for the entity to the rest of the application.
</p>]]></description>
      <pubDate>Tue, 02 Apr 2013 11:55:50 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Rob Allen: Objects in the model layer]]></title>
      <guid>http://www.phpdeveloper.org/news/19350</guid>
      <link>http://www.phpdeveloper.org/news/19350</link>
      <description><![CDATA[<p>
In <a href="http://akrabat.com/development/objects-in-the-model-layer/">this latest post</a> to his site <i>Rob Allen</i> talks some about application structure and the different kinds of objects he uses in his applications.
</p>
<blockquote>
I currently use a very simple set of core objects within my model layer: entities, mappers and service objects. [...] I dislike the phrase "service object" as the word "service" means so many things to so many people. I haven't heard a better phrase yet that everyone understands though.
</blockquote>
<p>
He defines each of the types of objects to help make the separation clearer. Here they are in brief:
</p>
<ul>
<li>Entities are objects that represent something in my business logic.
<li>Mappers know how to save and load an entity from the data store.
<li>Service objects provide the API that the rest of the application uses.
</ul>
<p>
Some of the comments on the post relate his choices to use in Zend Framework v2-based applications, noting that there are some base components you can extend to create these kinds of objects.
</p>]]></description>
      <pubDate>Fri, 22 Mar 2013 10:45:54 -0500</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[Igor Wiedler: Scaling a Silex code base]]></title>
      <guid>http://www.phpdeveloper.org/news/18721</guid>
      <link>http://www.phpdeveloper.org/news/18721</link>
      <description><![CDATA[<p>
<i>Igor Wiedler</i> has a new post to his site today talking about <a href="https://igor.io/2012/11/09/scaling-silex.html">scaling Silex-based applications</a> (a microframework based on Symfony components) and using it for more than just the basic applications.
</p>
<blockquote>
One common misconception about <a href="http://silex.sensiolabs.org/">silex</a> and microframeworks in general is that they are only suited for small, simple apps, APIs and prototyping. Of course, those use cases are the main selling point, but they are by no means the limit of what is possible.
</blockquote>
<p>
He shares some code that's the common "first steps" for someone using the framework, but points out a better way - moving your controller handling out into separate files instead. With a built-in feature of Silex, you can specify the "path" to another class file that will handle the request and return the response back to the main app. He also suggests extracting even more of the functionality out into "service" classes to handle the processing, cleaning up the controllers even more. He finishes off the post with a brief comparison between Silex and a full Symfony2 application, noting that Silex is a bit more "free form" when it comes to structure where Symfony2 apps are pretty well defined and have their conventions.
</p>]]></description>
      <pubDate>Fri, 09 Nov 2012 10:55:04 -0600</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[Dave Marshall: Silex Controllers as Services]]></title>
      <guid>http://www.phpdeveloper.org/news/18549</guid>
      <link>http://www.phpdeveloper.org/news/18549</link>
      <description><![CDATA[<p>
<i>Dave Marshall</i> has written up a post about how he <a href="http://davedevelopment.co.uk/2012/10/03/Silex-Controllers-As-Services.html">uses Silex controllers as services</a> that allow him to define his controller methods in separate classes with a custom resolver.
</p>
<blockquote>
There's currently a pull request in the queue for <a href="http://silex.sensiolabs.org/">Silex</a> that adds a cookbook entry for using controller classes, but I wanted to take it a step further and have my controllers as services, much like <a href="http://symfony.com/doc/current/cookbook/controller/service.html">what's possible</a> with the full symfony framework (See <a href="http://richardmiller.co.uk/2011/04/15/symfony2-controller-as-service/">Richard Miller's post</a> for further reading).
</blockquote>
<p>
He includes some example code showing the creation of the Silex application with a service definition, the custom "ControllerResolver" to override the default and a simple controller class ("PostController") that just returns a JSON response. You can find the full example code for it <a href="https://github.com/davedevelopment/silex-service-controllers">on github</a>.
</p>]]></description>
      <pubDate>Wed, 03 Oct 2012 09:36:15 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jurian Sluiman: Using Zend Framework service managers in your application]]></title>
      <guid>http://www.phpdeveloper.org/news/18548</guid>
      <link>http://www.phpdeveloper.org/news/18548</link>
      <description><![CDATA[<p>
<i>Jurian Sluiman</i> has a new post to his site showing how to <a href="http://juriansluiman.nl/en/article/120/using-zend-framework-service-managers-in-your-application">use the service managers</a> in your Zend Framework v2 applications.
</p>
<blockquote>
Zend Framework 2 uses a ServiceManager component (in short, SM) to easily apply inversion of control. I notice there are good resources about the background of service managers (I recommend <a href="http://blog.evan.pro/introduction-to-the-zend-framework-2-servicemanager">this blog post from Evan</a> or <a href="http://zendblog.shinymayhem.com/2012/09/using-servicemanager-as-inversion-of.html">this post from Reese Wilson</a>) but many people still have problems to tune the SM to their needs. In this post I will try to explain the reason why the framework uses multiple service managers and how you can use these. 
</blockquote>
<p>
He talks about the different service managers that are available in the framework, why they're used, how they relate to the service locator and how you can define/fetch your own services in them. He includes some basic configuration code and compares the behavior of the root service manager to the others (application services, controllers, view helpers, etc).
</p>]]></description>
      <pubDate>Wed, 03 Oct 2012 08:52:39 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Building Your Own URL Shortener]]></title>
      <guid>http://www.phpdeveloper.org/news/18506</guid>
      <link>http://www.phpdeveloper.org/news/18506</link>
      <description><![CDATA[<p>
On PHPMaster.com today, there's a new tutorial walking you through the <a href="http://phpmaster.com/building-your-own-url-shortener/">creation of a URL shortner</a> - a simple tool that can be used to compact URLs into something easier to manage (and more friendly with services like Twitter).
</p>
<blockquote>
Most of us are familiar with seeing URLs like bit.ly or t.co on our Twitter or Facebook feeds. These are examples of shortened URLs, which are a short alias or pointer to a longer page link.  [...] In this article you'll learn how to create a fully functional URL shortener for your website that will work whether you use a front controller/framework or not. If you use a front controller, I'll discuss you how to easily integrate this URL shortener without having to dig into the controller's programming.
</blockquote>
<p>
They help you create a simple database to hold the link relationships, the PHP code to create the randomized hash that represents the link and the code to shorten it. There's also the PHP code to take it the other way and decode the shortened version into the full URL. You can find the full code (ready for checkout) over on <a href="https://github.com/phpmasterdotcom/BuildingYourOwnURLShortener">the PHPMaster.com Github account</a>.
</p>]]></description>
      <pubDate>Fri, 21 Sep 2012 12:58:00 -0500</pubDate>
    </item>
  </channel>
</rss>
