<?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, 19 May 2013 03:52:21 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[DPCRadio: Episode #2012-27 - Elizabeth Smith's "SPL in the Wild"]]></title>
      <guid>http://www.phpdeveloper.org/news/18731</guid>
      <link>http://www.phpdeveloper.org/news/18731</link>
      <description><![CDATA[<p>
The Dutch PHP Conference has posted their latest podcast in their DPCRadio series as recorded at this year's Dutch PHP Conference - <i>Elizabeth Smith</i>'s <a href="http://www.phpconference.nl/blog/775_dpcradio-4">SPL in the Wild</a>:
</p>
<blockquote>
The standard PHP library (SPL) is growing in both maturity and use. But a lot of developers still aren't aware of the tools in SPL or simply haven't seen good examples of how to use the code. From interfaces to an autoload stack to classes that make objects act like arrays, there are tools to make every application leaner and faster, or simply more clever. Using live projects from github, take a look at the good, bad, and the ugly of SPL usage in PHP development.
</blockquote>
<p>
You can listen to this latest episode either via the <a href="http://www.phpconference.nl/blog/775_dpcradio-4">in-page player</a> or by <a href="http://dpcradio.s3.amazonaws.com/2012_027.mp3">downloading it directly</a>. You can also <a href="https://itunes.apple.com/nl/podcast/dpc-radio/id568825964">subscribe to their feed</a> and get the latest as they're released.
</p>]]></description>
      <pubDate>Mon, 12 Nov 2012 12:53:38 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[MaltBlue.com: Painless Data Traversal with PHP FilterIterators]]></title>
      <guid>http://www.phpdeveloper.org/news/18654</guid>
      <link>http://www.phpdeveloper.org/news/18654</link>
      <description><![CDATA[<p>
On the MaltBlue blog <i>Matt Setter</i> has a new post introducing you to <a href="http://www.maltblue.com/php/painless-data-traversal-with-php-filteriterators">using FilterIterators for data traversal</a>:
</p>
<blockquote>
There's load of ways to traverse data, especially in PHP where there are a variety of loops available; including while, do while, for and foreach. These are fine for normal structures, such as scalar and associative arrays. But what if you want to get a bit more fancy?
</blockquote>
<p>
He includes a bit of code showing the typical looping approach that a lot of developers take and how, using a <a href="http://php.net/filteriterator">FilterIterator</a>, you can extend the default and make a custom "accept" method to remove certain matching items from the data set.
</p>]]></description>
      <pubDate>Thu, 25 Oct 2012 08:54:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: List Files and Directories with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/18644</guid>
      <link>http://www.phpdeveloper.org/news/18644</link>
      <description><![CDATA[<p>
On PHPMaster.com there's a new tutorial showing you how to <a href="http://phpmaster.com/list-files-and-directories-with-php/">work with files and directories</a> through your PHP applications. 
</p>
<blockquote>
In this article I'll talk about a common task you might have experienced while developing a PHP application: listing files and directories. I'll discuss several basic and advanced solutions, each having its pros and cons. First I'll present three approaches that use some very basic PHP functions and then progress to more robust ones which make use of SPL Iterators.
</blockquote>
<p>
The solutions they look at are the built-in functions like <a href="http://php.net/glob">glob</a> and <a href="http://php.net/readdir">readdir</a>/<a href="http://php.net/opendir">opendir</a> as well as SPL iterators up for the task - FilesystemIterator, RecursiveDirectoryIterator and GlobIterator. Code samples are included in the post, showing how to use each method to get and list the files. A few helpful hints are also included to finish off the tutorial (mostly about "tricks" to using the functions effectively).
</p>]]></description>
      <pubDate>Tue, 23 Oct 2012 08:56:25 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Using SPL Iterators, Part 2]]></title>
      <guid>http://www.phpdeveloper.org/news/17986</guid>
      <link>http://www.phpdeveloper.org/news/17986</link>
      <description><![CDATA[<p>
On PHPMaster.com today they've posted the <a href="http://phpmaster.com/using-spl-iterators-2/">second part of the series</a> covering the Iterators that come with PHP as a part of the <a href="http://php.net/spl">SPL</a>.
</p>
<blockquote>
In <a href="http://phpmaster.com/using-spl-iterators-1">part one</a> of this series I introduced you to some of the SPL Iterators and how to use them. There may be times however when the provided iterators are insufficient for your needs and you'll want to roll your own custom iterator. Luckily, SPL provides interfaces that will allow you to do just that. For an object to be traversable in a foreach loop, PHP requires that it be an instance of Traversable. You cannot however implement this interface directly (though you can use it in instaceof checks); instead you'll need to implement either SPL's Iterator or IteratorAggregate interfaces.
</blockquote>
<p>
He shows you how to implement these two interfaces in your own custom classes, looping through a set of books for the Iterator example and a "getIterator" method that creates an <a href="http://php.net/arrayiterator">ArrayIterator</a> when executed. The results of both are used in foreach loops showing how they can be used just like any other iteratable variables.
</p>]]></description>
      <pubDate>Tue, 22 May 2012 08:23:17 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Using SPL Iterators, Part 1]]></title>
      <guid>http://www.phpdeveloper.org/news/17962</guid>
      <link>http://www.phpdeveloper.org/news/17962</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial posted, the first part of a series, looking at the use of the <a href="http://php.net/spl">Standard PHP Library (SPL)</a> in PHP. In <a href="http://phpmaster.com/using-spl-iterators-1/">this first part</a> of the series, <i>Stefan Froelich</i> looks specifically at two of the more common uses for iterators - working with arrays and directories.
</p>
<blockquote>
When I first came across the term iteration and saw the overwhelming list of classes related to it in the SPL, I was taken aback. It seemed maybe iteration was too complex for me to grasp. I soon realized it was just a fancy word for something we programmers do all the time. [...] In the first part of this two-part series I'll introduce you to iteration and how you can take advantage of some of the built-in classes from the Standard PHP Library (SPL).
</blockquote>
<p>
Included in the tutorial is example code showing how to use the <a href="http://php.net/arrayiterator">ArrayIterator</a> to work with an array and the <a href="http://php.net/directoryiterator">DirectoryIterator</a> to process the contents of a directory. He also briefly touches on a few other iterators like "FileExtensionFilter", "RecursiveDirectoryIterator" and "RecursiveArrayIterator".
</p>]]></description>
      <pubDate>Tue, 15 May 2012 12:26:59 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Stefan Koopmanschap's Blog: GlobIterator: Easy access to specific files]]></title>
      <guid>http://www.phpdeveloper.org/news/17828</guid>
      <link>http://www.phpdeveloper.org/news/17828</link>
      <description><![CDATA[<p>
<i>Stefan Koopmanschap</i> has a new post to his blog showing a <a href="http://www.leftontheweb.com/message/GlobIterator_Easy_access_to_specific_files">handy use of the GlobIterator</a> to access only certain files.
</p>
<blockquote>
For a project I am working on I needed to iterate over all .xml files in a specific directory. I started out with a DirectoryIterator, then considered I didn't want the XML filtering to take place inside my foreach loop. I decided to add a FilterIterator to the setup, but then felt this was not the right solution either. So I turned to my favorite SPL guru, <a href="http://adayinthelifeof.nl/">Joshua Thijssen</a>, to see if I was overseeing some kind of filter-option in the DirectoryIterator. I didn't, but I did oversee something else: <a href="http://php.net/globiterator">GlobIterator</a>.
</blockquote>
<p>
The GlobIterator lets you use functionality similar to the <a href="http://php.net/glob">glob</a> function (including being able to use wildcards in file searching) and get the resulting list back as a set of SplFileInfo objects, complete with additional metadata that can be extracted. 
</p>]]></description>
      <pubDate>Tue, 17 Apr 2012 12:43:42 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jeremy Cook's Blog: Implementing the ArrayAccess Interface]]></title>
      <guid>http://www.phpdeveloper.org/news/17490</guid>
      <link>http://www.phpdeveloper.org/news/17490</link>
      <description><![CDATA[<p>
<i>Jeremy Cook</i> is back with the next part of his series looking at the handy features PHP's <a href="http://php.net/spl">SPL</a> provides. In <a href="http://jeremycook.ca/2012/01/22/implementing-the-arrayaccess-interface/">this new post</a> he looks at the ArrayAccess interface and how it can make your data more accessible to PHP's own array handing functions.
</p>
<blockquote>
ArrayAccess allows you to treat an object that implements it as if it is an array for the purposes of setting, unsetting and retrieving data from it. Please note the emphasis in the last sentence! ArrayAccess does not make an object behave like an array in any other way. If you pass an object that implements ArrayAccess to a PHP array function such as in_array() you'll still get an error. This will become a little clearer with some of the examples below.
</blockquote>
<p>
He shows what you'll need to use this interface in your class - implementing the interface and defining a set of four methods to get/set and check for the value in your array. He includes a practical example of pulling data back from an API and wrapping it in a class to make accessing it simpler (also implementing the Countable interface as well, see the <a href="http://jeremycook.ca/2012/01/01/using-the-countable-interface/">previous post</a> for more on that). Code is include to illustrate how it can be used.
</p>]]></description>
      <pubDate>Thu, 02 Feb 2012 13:56:43 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jeremy Cook's Blog: Using the Countable Interface]]></title>
      <guid>http://www.phpdeveloper.org/news/17354</guid>
      <link>http://www.phpdeveloper.org/news/17354</link>
      <description><![CDATA[<p>
In a recent post to his blog <i>Jeremy Cook</i> has a tutorial <a href="http://jeremycook.ca/2012/01/01/using-the-countable-interface/">about using the Countable interface</a> (part of the SPL) in your objects to make them play nicely with functions like <a href="http://php.net/count">count</a>.
</p>
<blockquote>
PHP provides a number of predefined interfaces and classes that can really make your life as a developer easier but which are often overlooked. The functionality offered by the <a href="http://ca2.php.net/manual/en/book.spl.php">Standard PHP Library (SPL)</a> and the <a href="http://ca2.php.net/manual/en/reserved.interfaces.php">predefined interfaces</a> is extremely cool and very powerful but very underutilized. [...] I thought I'd write a few articles with examples of how I've used these classes and interfaces in the hope that someone would find it useful. I'd love it if people felt like commenting with their own examples too. I'll start with a quick look at the Countable interface.
</blockquote>
<p>
He includes sample code for classes using the Countable interface and defining the custom "count()" method inside. This method lets you define how the object will behave when something like <a href="http://php.net/count">count</a> is called on it. His examples show returning the number of items in a private variable, determining the state of an object and including logic to only find valid data (like from a database table).
</p>]]></description>
      <pubDate>Thu, 05 Jan 2012 14:39:05 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: PHP Arrays: Advanced Iteration and Manipulation]]></title>
      <guid>http://www.phpdeveloper.org/news/17238</guid>
      <link>http://www.phpdeveloper.org/news/17238</link>
      <description><![CDATA[<p>
In <a href="http://www.phpbuilder.com/columns/php_arrays/PHP_Arrays_12-8-2011.php3">this new tutorial</a> from PHPBuilder.com, <i>Jason Gilmore</i> shows you some of the more advanced things you can do with arrays in PHP (specifically in the areas of iterating through them and manipulating their contents).
</p>
<blockquote>
Sporting more than 70 native array-related functions, PHP's array manipulation capabilities have long been one of the language's most attractive features. [...] There are however many array-related tasks which ask a bit more of the developer than merely knowing what part of the manual one needs to consult. Many such tasks require a somewhat more in-depth understanding of the native features, or are possible only when a bit of imagination is applied to the problem.
</blockquote>
<p>
In his examples he shows how to do things like sorting a multi-dimensional array, iterating recursively (with the help of a <a href="http://www.php.net/manual/en/class.recursivearrayiterator.php">RecursiveArrayIterator</a>), converting an object to an array and doing "natural" sorting on an array's contents.
</p>]]></description>
      <pubDate>Fri, 09 Dec 2011 12:50:11 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Joshua Thijssen's Blog: SPL: Using the iteratorAggregate interface]]></title>
      <guid>http://www.phpdeveloper.org/news/17216</guid>
      <link>http://www.phpdeveloper.org/news/17216</link>
      <description><![CDATA[<p>
<i>Joshua Thijssen</i> has a <a href="http://www.adayinthelifeof.nl/2011/12/04/spl-using-the-iteratoraggregate-interface/">recent post</a> spotlighting a part of the <a href="http://php.net/spl">Standard PHP Library</a> (SPL) that implements that Traversable interface, the <a href="http://www.php.net/iteratorAggregate">IteratorAggregate</a> interface.
</p>
<blockquote>
Together with its more famous brother "Iterator", they are currently the two only implementations of the "Traversable" interface, which is needed for objects so they can be used within a standard foreach() loop. But why and when should we use the iteratorAggregate?
</blockquote>
<p>
He answers his question with an example - a book that contains chapters. With a normal iterator you'd have to define standard functions (like valid, rewind or key). Using the IteratorAggregate you can push items into an internal array (like chapters in a book) and call a "getIterator" method to get this set. He also takes it one step further and shows implementing the "Count" interface to make it easier to get a total count of the items in the iterator. Sample code is included to help clarify.
</p>]]></description>
      <pubDate>Tue, 06 Dec 2011 08:28:45 -0600</pubDate>
    </item>
  </channel>
</rss>
