News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthew Weier O'Phinney's Blog:
Applying FilterIterator to Directory Iteration
August 17, 2010 @ 10:29:38

New on his blog Matthew Weier O'Phinney has this post looking about using the FilterIterator (from PHP's SPL libraries) to work with (recursive) directory iteration.

I'm currently doing research and prototyping for autoloading alternatives in Zend Framework 2.0. One approach I'm looking at involves creating explicit class/file maps; these tend to be much faster than using the include_path, but do require some additional setup. [...] I'm well aware of RecursiveDirectoryIterator, and planned to use that. However, I also had heard of FilterIterator, and wondered if I could tie that in somehow. In the end, I could, but the solution was non-obvious.

He starts with what he thought he should be able to do with the FilterIterator - pass in a DirectoryIterator to be able to filter them recursively. Unfortunately this only worked for the first level, so he looked else where. His solution ultimately involved passing in a RecursiveIteratorIterator instance into the DirectoryIterator that contained his RecursiveDirectoryIterator. He includes a full code example in the post showing how to locate a certain file/class recursively inside a directory.

0 comments voice your opinion now!
iterator spl filteriterator directory tutorial


blog comments powered by Disqus

Similar Posts

O'Reilly: Code As Data: Reflection in PHP

Mfana Ronald Conco's Blog: RabbitMQ and PHP Part 1

TechChorus Blog: Create RESTful Applications Using The Zend Framework - Part II: Using HTTP Response

Wes Ray's Blog: Configuring Fedora 12 PHP/MySQL Server with Nginx and reverse proxy to Apache

Brandon Savage's Blog: Bug-Free: Your Bug-Fixing Toolkit (Part 1 of N)


Community Events











Don't see your event here?
Let us know!


package framework performance hhvm application project unittest symfony2 install podcast facebook hack threedevsandamaybe introduction component security release composer language database

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework