<?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:15:51 -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[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[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[Robert Basic's Blog: A Zend Framework 2 EventManager use case]]></title>
      <guid>http://www.phpdeveloper.org/news/17021</guid>
      <link>http://www.phpdeveloper.org/news/17021</link>
      <description><![CDATA[<p>
<i>Robert Basic</i> has a new post to his blog today with an <a href="http://robertbasic.com/blog/azend-framework-2-eventmanager-use-case/">use case for Zend Framework 2's event manager</a> to solve a problem he has with "repetitive code" in some of his models.
</p>
<blockquote>
Basically, this allows us to have one piece of code to trigger an event and to have one or more listeners listening to this event. When the event gets triggered, the listeners are called and then we can do *something*, like caching or logging. Logging or caching. [...] See, that's my problem. All the event examples stop at logging and caching. Truly there must be some other example for which this event stuff can be used for.
</blockquote>
<p>
In his example code, he's used the EventManager in one of his models to add listeners to validate the post and "slugify" the post's title for use on the URL. You can <a href="https://github.com/robertbasic/blog-examples/blob/master/zf2-event-manager/index.php">find his code on github</a> if you're interested in the full implementation.
</p>]]></description>
      <pubDate>Thu, 20 Oct 2011 11:05:43 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Adam Jensen's Blog: Using Zend_Acl with Doctrine record listeners]]></title>
      <guid>http://www.phpdeveloper.org/news/13589</guid>
      <link>http://www.phpdeveloper.org/news/13589</link>
      <description><![CDATA[<p>
<i>Adam Jensen</i> has <a href="http://jazzslider.org/2009/11/25/using-zend-acl-with-doctrine-record-listeners">written up a quick tutorial</a> about using Doctrine record listeners to link a Zend_Acl component with your database.
</p>
<blockquote>
In previous Zend Framework apps I've written, I often handled access control at the level of the controller action. Each action was represented in the ACL as a resource, and the ACL logic was applied by a custom plugin just prior to any action dispatch. [...] As a result of these concerns, I decided on a lower-level, model-centric approach for this blog: my models are my resources. Each model class implements Zend_Acl_Resource_Interface, and the ACL specifies "create," "read," "update" and "destroy" privileges for each class (more or less).
</blockquote>
<p>
Checking for the permissions with a setup like this can be time consuming, though, so he found an ally in the record listeners Doctrine allows you to set. He combines a Doctrine_Record_Listener object with a Zend_Acl one in a preInsert method with a getCurrentRole to add the user handling all in one place.
</p>]]></description>
      <pubDate>Wed, 25 Nov 2009 11:53:29 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[CodeUtopia Blog: Database helper for PHPUnit]]></title>
      <guid>http://www.phpdeveloper.org/news/10917</guid>
      <link>http://www.phpdeveloper.org/news/10917</link>
      <description><![CDATA[<p>
On the CodeUtopia blog there's a <a href="http://codeutopia.net/blog/2008/08/27/database-helper-for-phpunit/">recent post</a> with info on creating a custom event listener in PHPUnit that can help keep you database data completely clean.
</p>
<blockquote>
When testing code which uses the database, you would usually want to make sure the database stays pristine for each test - All tables should be empty, as any extra data could interfere with the tests. You could probably write an extended Testcase class which automatically does this before each test in setUp and afterwards in tearDown, but it may have some issues. [...] Luckily, PHPUnit has a way to add event listener that react to certain events.
</blockquote>
<p>
It uses the <a href="http://www.phpunit.de/pocket_guide/3.3/en/phpunit-book.html#extending-phpunit.PHPUnit_Framework_TestListener">TestListener interface</a> to make the event handler that (with the help of Doctrine) starts up, makes the tables with data and wipes them out at the end. 
</p>
<p>
Code for the sample listener is in the post and included is the method for checking to see if you even need to use the database or not.
</p>]]></description>
      <pubDate>Thu, 28 Aug 2008 10:22:12 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[WebDevRadio: Episode 40 - Listener questions]]></title>
      <guid>http://www.phpdeveloper.org/news/9106</guid>
      <link>http://www.phpdeveloper.org/news/9106</link>
      <description><![CDATA[<p>
The latest episode of <a href="http://www.webdevradio.com/">WebDevRadio</a> has been posted (by <i>Michael Kimsal</i>) - some responses to listener questions that have been sent to him.
</p>
<blockquote>
The latest <a href="http://www.webdevradio.com/">webdevradio</a> podcast is up.  One of the topics is a question for listeners about PHP learning resources; specifically, what are some good resources to learn PHP OO?  I also ask about what listeners would recommend to someone just getting in to the webdev field these days - .net, java, ruby, php, something else?
</blockquote>
<p>
You can either <a href="http://feeds.feedburner.com/WebdevradioPodcastHome">subscribe to their feed</a> to get this (and future episodes) or just <a href="http://www.webdevradio.com/get.php?web=podcast-webdevradio-2007-11-22-90589.mp3">get the mp3</a> only. He also has a web player <a href="http://www.webdevradio.com/index.php?id=58">on the post</a> to listen there as well.
</p>]]></description>
      <pubDate>Fri, 23 Nov 2007 12:20:32 -0600</pubDate>
    </item>
  </channel>
</rss>
