<?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:18:12 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Building A RESTful PHP Server: Routing the Request]]></title>
      <guid>http://www.phpdeveloper.org/news/17433</guid>
      <link>http://www.phpdeveloper.org/news/17433</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> is back with a second installment in her "Building a RESTful PHP Server" series with <a href="http://www.lornajane.net/posts/2012/building-a-restful-php-server-routing-the-request">this new post</a> about handling and routing the incoming requests. (You can find the first part about working with the request <a href="http://phpdeveloper.org/news/17418">here</a>)
</p>
<blockquote>
This is the second part of a series, showing how you might write a RESTful API using PHP. This part covers the routing, autoloading, and controller code for the service, and follows on from the first installment which showed how to parse the incoming request to get all the information you need.
</blockquote>
<p>
She shows how to grab the controller name from the incoming request (based on her previous code), create the object for it and execute the requested action name. Also included is a sample autoloader and a basic controller - a UsersController with "getAction" and "postAction" 
 methods for responding to GET and POST requests.
</p>]]></description>
      <pubDate>Mon, 23 Jan 2012 11:14:11 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 6)]]></title>
      <guid>http://www.phpdeveloper.org/news/17391</guid>
      <link>http://www.phpdeveloper.org/news/17391</link>
      <description><![CDATA[<p>
In the <a href="http://fabien.potencier.org/article/55/create-your-own-framework-on-top-of-the-symfony2-components-part-6">sixth part of his series</a> on creating a custom framework on top of the Symfony2 components, <i>Fabien Potencier</i> looks at how to improve the previous examples by swapping out the more procedural controllers with actual classes.
</p>
<blockquote>
The move is pretty straightforward and makes a lot of sense as soon as you create more pages but you might have noticed a non-desirable side-effect... The LeapYearController class is always instantiated, even if the requested URL does not match the leap_year route. This is bad for one main reason: performance wise, all controllers for all routes must now be instantiated for every request. It would be better if controllers were lazy-loaded so that only the controller associated with the matched route is instantiated.
</blockquote>
<p>
To help solve the issue, he uses the HttpKernel component and its "controller resolver" to figure out how to call the controller and pass it the correct parameters, but only when needed. A resolver object is created and that is used to instantiate the controller object. Sample "action" calls are included to fill out the basic controller (his "leap year" example) and the full resulting code is included both for the framework and the new object oriented controller.
</p>]]></description>
      <pubDate>Fri, 13 Jan 2012 11:08:12 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 5)]]></title>
      <guid>http://www.phpdeveloper.org/news/17384</guid>
      <link>http://www.phpdeveloper.org/news/17384</link>
      <description><![CDATA[<p>
<i>Fabien Potencier</i> has posted the <a href="http://fabien.potencier.org/article/54/create-your-own-framework-on-top-of-the-symfony2-components-part-5">fifth part</a> of his series looking at building a custom framework on top of the <a href="http://symfony.com">Symfony2</a> components. In this new tutorial he adds in one of the major features of any framework - the controller level.
</p>
<blockquote>
For simple pages like the ones we have created so far, that's not a problem, but if you want to add more logic, you would be forced to put the logic into the template itself, which is probably not a good idea, especially if you still have the separation of concerns principle in mind. Let's separate the template code from the logic by adding a new layer: the controller: The controller mission is to generate a Response based on the information conveyed by the client Request.
</blockquote>
<p>
He updates the template rendering to use an external method instead of doing it itself and updates the routing to include a "_controller" attribute pointing to the method. The full code for the updated version of the framework is included - a simple request/response with handling for a "leap_year" route.
</p>]]></description>
      <pubDate>Thu, 12 Jan 2012 10:48:17 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Karsten Deubert's Blog: Zend_MVC, Controller Plugins and Annotations]]></title>
      <guid>http://www.phpdeveloper.org/news/17178</guid>
      <link>http://www.phpdeveloper.org/news/17178</link>
      <description><![CDATA[<p>
<i>Karsten Deubert</i> has a recent post to his blog looking at <a href="http://www.logaholic.de/2011/11/25/zend_mvc-controller-plugins-and-annotations/">annotations in Zend Framework applications</a> to enhance functionality already in the framework.
</p>
<blockquote>
Recently I had the idea to influence Controller Actions with annotations but discarded it with thoughts like "In PHP I will have to use reflection and some black magic to get this working which will have insane performance hits for my applications"... until I set everything up to see that it costs just 1-2ms in average per request without any form of caching.
</blockquote>
<p>
He includes a few bits of code to show a simple annotation example (setting a layout) and the controller plugin that performs the translation. In his case, it's hard-coded to look for the "@layout" annotation in the docblock comment, but it'd be relatively trivial to extend it to a more full-featured version.
</p>]]></description>
      <pubDate>Mon, 28 Nov 2011 12:02:50 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: Building RESTful Web Services with the Zend Framework]]></title>
      <guid>http://www.phpdeveloper.org/news/17120</guid>
      <link>http://www.phpdeveloper.org/news/17120</link>
      <description><![CDATA[<p>
New on PHPBuilder.com today is a tutorial introducing you to <a href="http://www.phpbuilder.com/columns/RESTful_Web_Services_with_Zend/RESTful_Web_Services_with_Zend_11-03-2011.php3">web services with the Zend Framework</a>, a guide to creating a simple RESTful service with this popular PHP framework.
</p>
<blockquote>
Rather than attempt to build and maintain multiple versions of the Web application in order to accommodate the diverse array of challenges and advantages presented by each device type, developers are increasingly embracing a unified approach which allows them to manage a single server-side code base which communicates with multiple client-specific interfaces by way of a RESTful Web service. The Zend Framework's <a href="http://framework.zend.com/manual/en/zend.rest.html">Zend_Rest</a> component offers PHP developers with an incredibly straightforward approach to building RESTful Web services. 
</blockquote>
<p>
He shows how to set up some internal RESTful routing (with the help of <a href="http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.rest">Zend_Rest_Route</a>) and create a simple controller that responds to several of the major HTTP request types - POST, GET, PUT, etc. In his simple example, he shows how to update a basic TODO list with a POST and the JSON response that would follow.
</p>]]></description>
      <pubDate>Fri, 11 Nov 2011 11:37:45 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[David Stockton's Blog: Changing ErrorController to work with AJAX]]></title>
      <guid>http://www.phpdeveloper.org/news/16709</guid>
      <link>http://www.phpdeveloper.org/news/16709</link>
      <description><![CDATA[<p>
<i>David Stockton</i> has a new tutorial posted to his blog - a technique he's found useful in his Zend Framework application to make the <a href="http://zendtutorials.com/tutorial/changing-errorcontroller-to-work-with-ajax/">ErrorController work with Ajax calls</a> to reduce the message you get back to just a JSON response.
</p>
<blockquote>
If you've ever built a Zend Framework MVC app which makes AJAX calls, you may have noticed that if an error occurs, you'll get a chunk of JSON followed by the HTML for the error page. If you've built a layout, you'll get all of that back to. This is fine if your users hit the page in the browser but it can cause problems with your JavaScript being able to correctly decode your JSON.
</blockquote>
<p>
The fix is pretty simple, though, and only requires that you add the error handling action to the Ajax context to force it to drop the layout and any other HTML that might come along with the view. He includes a bit more code to have the error handler include the exceptions and pass them out to be included in the JSON response.
</p>]]></description>
      <pubDate>Fri, 12 Aug 2011 08:58:06 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Richard Miller's Blog: Symfony2: Moving Away From the Base Controller]]></title>
      <guid>http://www.phpdeveloper.org/news/16468</guid>
      <link>http://www.phpdeveloper.org/news/16468</link>
      <description><![CDATA[<p>
<i>Richard Miller</i> has a new post to his blog today that recommends <a href="http://miller.limethinking.co.uk/2011/06/14/symfony2-moving-away-from-the-base-controller/">moving away from the base controller</a> the Symfony introductory documentation has you make. He suggests an alternative that can be used more widely.
</p>
<blockquote>
In fact, it is the advised <a href="http://symfony.com/doc/2.0/book/bundles.html#controllers">best practice for controllers in shared bundles</a>. When you do, you will no longer have access to these useful methods, in this post I am going to look at how to accomplish the same tasks without them. I have created a simple controller for some basic form interaction with a model which uses the base controllers methods. I am going to go through how to change this to a service which does not extend the base controller.
</blockquote>
<p>
He starts with his "TestimonialController" that does some of the basic CRUD operations on the testimonial information. He shows you, step-by-step, the refactoring needed to stop using things like the default controller helpers (each with replacement code). With those removed, he can move to extend "ContainerAware" instead of "Controller", make the controller a service and doing some dependency injection for needed resources.
</p>]]></description>
      <pubDate>Tue, 14 Jun 2011 13:23:15 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Symfony Blog: Symfony2: Annotations gets better]]></title>
      <guid>http://www.phpdeveloper.org/news/16372</guid>
      <link>http://www.phpdeveloper.org/news/16372</link>
      <description><![CDATA[<p>
<i>Fabien Potencier</i> has posted another in his "getting better" series looking at the features that are included in the Symfony2 framework. In <a href="http://symfony.com/blog/symfony2-annotations-gets-better">this new post</a> he talks about the improvement annotation support.
</p>
<blockquote>
Later today, I will release Symfony2 beta2. But first, I wanted to talk about a big change that landed into master yesterday. As you might know, Symfony2 uses annotations for Doctrine mapping information and validation configuration. Of course, it is entirely optional, and the same can be done with XML, YAML, or even PHP. But using annotations is convenient and allows you to define everything in the same file.
</blockquote>
<p>
Two new bundles were added, SensioFrameworkExtraBundle and JMSSecurityExtraBundle, that let you use annotations in the controller for configuration. Examples of this new feature are included in the post giving the configuration settings a more "native" feel.
</p>]]></description>
      <pubDate>Mon, 23 May 2011 11:08:53 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jani Hartikainen's Blog: You don't need a service layer: Fat controllers are okay]]></title>
      <guid>http://www.phpdeveloper.org/news/16369</guid>
      <link>http://www.phpdeveloper.org/news/16369</link>
      <description><![CDATA[<p>
<i>Jani Hartikainen</i> has a new post to his blog today about why, in your framework-based applications, it's <a href="http://codeutopia.net/blog/2011/05/22/you-dont-need-a-service-layer-fat-controllers-are-okay/">okay to have "fat controllers"</a> instead of a service layer.
</p>
<blockquote>
Here's a counterpoint to the currently popular view of "fat controllers are bad", and the current fad of everyone and their cousin implementing service layers: You don't need one. Fat controllers are okay too.
</blockquote>
<p>
He starts by explaining the "why you don't need a service layer" part, mentioning that keeping it in the controller keeps things simple and keeps your code from having to go through extra hoops just to work correctly. He also points out that, just because he recommends "fat controllers" doesn't mean he's advocating code reuse. In fact, just the opposite:
</p>
<blockquote>
It's fine if you code your things in the controllers, but there comes a point when you should stop that. The moment you realize you're duplicating your code, stop and refactor. This is one of the very basics of software engineering: Avoid duplication by creating functions and classes.
</blockquote>]]></description>
      <pubDate>Mon, 23 May 2011 08:42:15 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Robert Basic's Blog: Grouping Zend Framework controllers in subdirectories]]></title>
      <guid>http://www.phpdeveloper.org/news/16210</guid>
      <link>http://www.phpdeveloper.org/news/16210</link>
      <description><![CDATA[<p>
<i>Robert Basic</i> has a new post today showing you how you can <a href="http://robertbasic.com/blog/grouping-zend-framework-controllers-in-subdirectories/">group your controllers</a> in your Zend Framework application into subdirectories for easier organization.
</p>
<blockquote>
Thanks to a discussion on the Zend Framework mailing list I learned about a new feature, a feature that allows for grouping action controllers in subdirectories! Well, this is more of an unknown and undocumented feature than new, as it is the part of the framework for at least 3 years. Why am I so hyped about this? Because it allows for better code organisation on larger projects. Heck, it might be useful on smaller ones too. 
</blockquote>
<p>
He gives <a href="https://lh5.googleusercontent.com/_7vS_Lw8rn0E/Tak8y6iMdcI/AAAAAAAAAlk/jKZ_BpYnUh4/subdirectories.png">an example</a> of how it might be laid out and a few helpful hints he learned when trying it out:
</p>
<ul>
<li>The subdirectory separator in the URI is the underscore and not the slash.
<li>The subdirectory name is uppercase: Subdirectory, not subdirectory. In the URI it's lowercase.
<li>The view directories for these subdirectories are lowercased, and not uppercase.
</ul>]]></description>
      <pubDate>Mon, 18 Apr 2011 09:08:25 -0500</pubDate>
    </item>
  </channel>
</rss>

