Zend_Filter

Decompressing archive files using the Zend Framework

Working with archives such as Zip, Tar, and Gz in PHP can be cumbersome at best and nightmarish at worst. The native Zip extension can be unpredictable and difficult to work with…but luckily, Zend to the rescue!

The Zend Framework has an extensive library of filter components that can modify and format your data in a dizzying array of different ways, including working with archives. The component we are interested is Zend_Filter_Decompress.

To decompress an archive file, we simply create an instance of the Zend_Filter_Decompress class, tell it which type of archive we are working with and where to save the decompressed files, then call the object’s filter() method, passing in the path to the archive file.

//Create filter object
$filter = new Zend_Filter_Decompress(array(
	'adapter' => 'Zip', //Or 'Tar', or 'Gz'
	'options' => array(
	    'target' => '/path/to/output/directory'
	)
));

$filter->filter('/path/to/archive/file.zip');

That’s all there is to it. If you look at the contents of your output directory, you’ll see the contents of your archive file. Compressing files into an archive is slightly more involved (but still simplified by the Zend Framework!) and will be covered in a future article.

Author: nick
Source: ZendCoding

Thomas Weidner’s Blog: Task updates

There is new post on Thomas Weidner’s blog, where he talks about he’s recent contribution to Zend_Framework. Zend_Framework 1.10 should be shipped with his new Zend_Filter_Boolean, new version of Zend_Validate_Barcode and Zend_View_Helper_Currency. Thomas is also working on I18N webinar.

So I am preparing some I18n webinars… the first will cover Basics of I18n, usage and internals of translation. Its mainly for beginners and people who want to get knowledge on workflow and some internals. Of course it will also cover some examples. When I am receive good responses on this webinar I will also cover other I18n themes.

New filters and validators

Zend Framework 1.10 development is moving forward. Last week Thomas Weidner published on his blog news about filters and validators added in Zend Framework 1.10:

Sounds like some of us can throw away our own code and switch to new, official filters and validators. Keep working hard Zend Framework team and soon we won’t have anything to do except for using Zend_Tool and running tests.