<?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 19:16:14 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Building A RESTful PHP Server: Output Handlers]]></title>
      <guid>http://www.phpdeveloper.org/news/17478</guid>
      <link>http://www.phpdeveloper.org/news/17478</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> is back with another post in her "Building a RESTful PHP Server" series today with <a href="http://www.lornajane.net/posts/2012/building-a-restful-php-server-output-handlers">this new post</a> showing how to work with output handlers (her focus is on JSON).
</p>
<blockquote>
So far we've covered parsing requests to determine exactly what the user is asking for, and also looked at routing to a controller to obtain the data or perform the action required. This post gives examples of how to return the data to the client in a good way.
</blockquote>
<p>
She advocates using output handlers instead of the usual views you'd think of in a typical MVCish sort of application. The difference here is that there's not a lot of extra overhead to produce the results - it's literally an output directly from a class extending the base view (including the correct headers). She also briefly mentions the inclusion of <a href="http://en.wikipedia.org/wiki/JSONP">JSONP</a> functionality, allowing you to specify a local callback to execute when the request is returned. A few other "nice to haves" are also mentioned like the number of results returned and pagination support.
</p>]]></description>
      <pubDate>Wed, 01 Feb 2012 10:25:33 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Targeted Geolocation with Geonames]]></title>
      <guid>http://www.phpdeveloper.org/news/17251</guid>
      <link>http://www.phpdeveloper.org/news/17251</link>
      <description><![CDATA[<p>
New on PHPMaster.com there's a tutorial from <i>Lukas White</i> about <a href="http://phpmaster.com/targeted-geolocation-with-geonames/">targeting users using geolocation</a> based on the <a href="http://www.geonames.org/">Geonames</a> web service and a latitude/longitude. His example makes a call to find the closest "place" to the given coordinates.
</p>
<blockquote>
Location-aware applications rely on being able to locate where you are, and this is what geolocation is all about. After all, once the application knows your location, it can go on to find the nearest store, guide you through the appropriate route to a destination, or target relevant advertisements to you. Geolocation, then, is simply the mechanism for identifying your geographical location.
</blockquote>
<p>
He mentions two challenges associated with geolocation - finding where someone is and describing the location. With Geonames, he shows how to call the service's "findNearbyPlaceName" method to find the closest "place" to a given latitude/longitude combination. Included is a bit of sample PHP to connect to the service and Javascript to request the user's current location.
</p>]]></description>
      <pubDate>Tue, 13 Dec 2011 12:10:02 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: POSTing JSON Data With PHP cURL]]></title>
      <guid>http://www.phpdeveloper.org/news/17161</guid>
      <link>http://www.phpdeveloper.org/news/17161</link>
      <description><![CDATA[<p>
On her blog today <i>Lorna Mitchell</i> has a quick tip for anyone having an issue sending POSTed JSON data with the <a href="http://php.net/curl">curl</a> functionality that can be built into PHP. The <a href="http://www.lornajane.net/posts/2011/posting-json-data-with-php-curl">trick to her method</a> is sending things with the right header.
</p>
<blockquote>
We can't send post fields, because we want to send JSON, not pretend to be a form (the merits of an API which accepts POST requests with data in form-format is an interesting debate). Instead, we create the correct JSON data, set that as the body of the POST request, and also set the headers correctly so that the server that receives this request will understand what we sent.
</blockquote>
<p>
She includes a code example (about ten lines) showing the POSTing process that sets up options using curl's <a href="http://php.net/curl_setopt">curl_setopt</a>. Be sure to set up the headers to send as "application/json" - that's the trick to letting the remote end know the format.
</p>]]></description>
      <pubDate>Tue, 22 Nov 2011 18:06:48 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[ZendCasts.com: Building a JSON End-Point With SLIM and jQuery: Part 2]]></title>
      <guid>http://www.phpdeveloper.org/news/17106</guid>
      <link>http://www.phpdeveloper.org/news/17106</link>
      <description><![CDATA[<p>
On ZendCasts.com today there's a new screencast in their "Building a JSON endpoint with the Slim microframework" series - <a href="http://www.zendcasts.com/building-a-json-end-point-with-slim-and-jquery-part-2/2011/11/">part two</a> focusing on jQuery integration. (Part one <a href="http://phpdeveloper.org/news/17044">is here</a>)
</p>
<blockquote>
[This screencast is] part 2 in a series on building a JSON end-point. We're using simple RESTful verbage to grab a list of names from a session store.
</blockquote>
<p>
You'll need to have the base scripts created in <a href="http://phpdeveloper.org/news/17044">part one</a> to follow along effectively. He picks up right where the previous part ends, creating a new view that uses some simple javascript (jQuery) code to pull the "names" values from his simple JSON endpoint. Also included is an example of a form for adding a new name to the list. The full source for the example can be <a href="https://gist.github.com/1346313">found over on github</a>.
</p>]]></description>
      <pubDate>Wed, 09 Nov 2011 10:04:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[ZendCasts.com: Building a JSON Endpoint with SLIM (Part 1)]]></title>
      <guid>http://www.phpdeveloper.org/news/17044</guid>
      <link>http://www.phpdeveloper.org/news/17044</link>
      <description><![CDATA[<p>
On ZendCasts.com today, the next part of their series looking at using the <a href="http://slimframework.com">Slim microframework</a> has been posted. This is <a href="http://www.zendcasts.com/building-a-json-endpoint-with-slim-part-1/2011/10/">part one</a> of a tutorial building a JSON endpoint for a web service.
</p>
<p>
You'll need some of the base that he created in <a href="http://www.zendcasts.com/slimming-out-your-controller/2011/10/">this previous screencast</a> to follow along (the basic structure, really). His takes his basic "hello world" application and builds on it to add a "model" to pull name data from and has the "/names" action respond with a JSON-formatted message (and an "application/json" content-type). His "model" pulls the data out with findAll() and find() methods.
</p>
<p>
You can <a href="https://gist.github.com/1314258">grab the source</a> to follow along.
</p>]]></description>
      <pubDate>Wed, 26 Oct 2011 10:51:45 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[SitePoint.com: How to Create an XML to JSON Proxy Server in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17016</guid>
      <link>http://www.phpdeveloper.org/news/17016</link>
      <description><![CDATA[<p>
On SitePoint.com today there's a new post from <i>Craig Buckler</i> showing you how to create a <a href="http://www.sitepoint.com/php-xml-to-json-proxy/">simple XML to JSON proxy server</a> in PHP with a SimpleXML object at its heart.
</p>
<blockquote>
Unless you're new to this web development lark, you'll know the 'X' in 'AJAX' stands for XML - eXtensible Markup Language. But you're probably not using XML. If you are, you'd probably prefer not to. All the cool kids are using JSON or JSON-P: it has a smaller payload, is easier to use and faster to process. [...] Fortunately, there are a couple of solutions which allow you to retain the benefits of XML data interchange but provide the ease of JSON in JavaScript. In this article, we're going to create an XML to JSON proxy server in PHP.
</blockquote>
<p>
Of course, this will only work with well-formatted XML documents, but it's a quick little hack that pulls in the XML data with a <a href="http://php.net/curl">curl</a> request and parses it via SimpleXML and uses <a href="http://php.net/json_encode">json_encode</a> to push it back out as JSON.
</p>
]]></description>
      <pubDate>Wed, 19 Oct 2011 13:07:08 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Abou Kone's Blog: Set up JSON action output in CakePHP 1.3]]></title>
      <guid>http://www.phpdeveloper.org/news/16962</guid>
      <link>http://www.phpdeveloper.org/news/16962</link>
      <description><![CDATA[<p>
<i>Abou Kone</i> has a recent post to his blog showing the CakePHP users out there how to <a href="http://aboukone.com/2011/10/04/set-up-json-action-output-in-cakephp-1-3/">set up JSON output</a> for your actions in a few simple steps.
</p>
<blockquote>
Working  on setting up the <a href="https://github.com/kvz/cakephp-rest-plugin">Rest Plugin</a> for CakePHP helped me realize that i wanted to set up JSON output for some of my actions. This way, if you request for example "www.yourapp.com/app/post/view/1.json" in the url, you will be returned the JSON post data. This <a href="http://blog.pagebakers.nl/2007/06/05/using-json-in-cakephp-12/">excellent tutorial here</a> will help you achieve it. 
</blockquote>
<p>
Changes include updates to configuration for routing, using the RequestHandler component and setting your actions to output the data correctly when the ".json" is detected on the request.
</p>]]></description>
      <pubDate>Fri, 07 Oct 2011 08:45:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Project: Patchwork-Doc - JSON Formatted Output of PHP variables]]></title>
      <guid>http://www.phpdeveloper.org/news/16960</guid>
      <link>http://www.phpdeveloper.org/news/16960</link>
      <description><![CDATA[<p>
<i>Nicolas Grekas</i> has submitted about a new tool he's developed to "represent faithfully any PHP variable as complex as it is" - <a href="https://github.com/nicolas-grekas/Patchwork-Doc/blob/master/Dumping-PHP-Data-en.md">Patchwork-Doc</a> (related to his <a href="https://github.com/nicolas-grekas/Patchwork">Patchwork</a> PHP framework).
</p>
<blockquote>
The JSON format on which it rests guarantees maximum interoperability while ensuring good readability. The implementation done in the JsonDumper class operates all potentialities of the representation while providing maximum latitude to the developer to exploit its ability as desired, both in term of exposure of internal class mechanism for specialization and in terms of custom use, thanks to the callbacks that allow to intercept the JSON line by line and to adjust the dumping of objects or resources according to their type.
</blockquote>
<p>
It isn't required to use the framework to use this tool, however. You can see an example of the output format in <a href="https://github.com/nicolas-grekas/Patchwork-Doc/blob/master/Dumping-PHP-Data-en.md">this example</a> on the project's github page, complete with a guide to some of the advantages and disadvantages of some of the current, more common methods of output. Several types are included in the example including simple string/integer values, objects, classes, stream resources and the results of variable casting.
</p>]]></description>
      <pubDate>Thu, 06 Oct 2011 12:16:58 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Johannes Schluter's Blog: mysqlnd plugins and json]]></title>
      <guid>http://www.phpdeveloper.org/news/16858</guid>
      <link>http://www.phpdeveloper.org/news/16858</link>
      <description><![CDATA[<p>
<i>Johannes Schluter</i> has <a href="http://schlueters.de/blog/archives/159-mysqlnd-plugins-and-json.html">shared a handy mysqlnd plugin</a> that he's written up that does two common things at once when you're pulling data from your database and pushing it into JSON - a mysqlnd_query_to_json function.
</p>
<blockquote>
In my spare time I'm currently writing a shiny Web 2.0 application where I'm heavily using AJAX-like things, so what I do quite often in this application is, basically this: Check some pre-conditions (permissions etc.) then select some data from the database, do a fetch_all to get the complete result set as an array and run it through json_encode; Of course that example is simplified as I'm using the Symfony 2 framework for this project. [...] So I wrote a mysqlnd plugin.
</blockquote>
<p>
His plugin (that he admits is "a hack") <a href="http://schlueters.de/blog/uploads/code/mysqlnd_query_to_json.tar.bz2">gives you the mysqlnd_query_to_json function</a> that automagically transforms the results from the passed in query into JSON output. He notes some things lacking - like Unicode encoding and no MySQL bitfield support.
</p>]]></description>
      <pubDate>Wed, 14 Sep 2011 11:04:48 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[David Stockton's Blog: Zend JSON - An Introduction]]></title>
      <guid>http://www.phpdeveloper.org/news/16763</guid>
      <link>http://www.phpdeveloper.org/news/16763</link>
      <description><![CDATA[<p>
<i>David Stockton</i> has a new post to his ZendTutorials.com site today introducing you to an increasingly more handy Zend Framework component that can make your messaging needs easier. The new tutorial <a href="http://zendtutorials.com/tutorial/zend-json-an-introduction/">introduces you to Zend_Json</a>, a component for generating and parsing JSON messages.
</p>
<blockquote>
In the past few years, JSON, or JavaScript Object Notation has seemed to overtake XML and other data encoding methods on the web. [...]  I've also seen numerous examples of developers who create their own sort of JSON encoder rather than either using json_encode or using Zend_Json. What inevitably comes back to bite them is when the data they are encoding contains a special character like quotes, colons, curly brackets, etc.
</blockquote>
<p>
He demonstrates how the Zend_Json component helps to alleviate some of the worries with built-in features that handle everything from basic encoding/decoding, printing out results in a "pretty" way and a handy way to include executable Javascript (once it's evaled on the other side) in your payload. He finishes the tutorial off with a mention of a very handy method that will please those already having to work with XML - the fromXML() method that automagically converts the data over to JSON for you.
</p>]]></description>
      <pubDate>Wed, 24 Aug 2011 08:17:12 -0500</pubDate>
    </item>
  </channel>
</rss>

