PHP and compression/archiving, with examples
Posted by: Floresense Team
PEAR package 'File_Archive': Amidst all these extensions that we tried in previous pages, we could also download a pear package, 'File_Archive' which actually bundles re-usable code as classes, for all popular compression formats.
'File_Archive' supports formats tar, gz, bz2, tgz, tbz, zip, ar and deb.
'File_Archive' has dependencies for all the supported formats. For example, it depends on installation of bz2 extension for supporting bz2, depends on 'Archive_Tar' pear package for supporting tar, etc.,
And as you would expect, because of these dependencies, 'File_Archive' is not a popular package on PEAR.
Since installing an extension itself opens up methods for coding on it rather than use another library to just reduce a few lines of code, using File_Archive may be an overhead on small implementations.
But, File_Archive good implementations for finding the appropriate compression/decompression methods to use based on the filename extension. And can be very useful in scenarios where we want to develop a script which should accept many uploaded files in different compression formats and extract them / read them.
'File_Archive' only has classes defined to read/write to file archives, or create/read compressed files. Its more like an easy include file which can reduce number of lines of code you will write in your script file.
You can download 'File_Archive' PEAR package from here http://pear.php.net/package/File_Archive, or install using pearInstaller like mentioned here http://www.floresense.com/resc_center/?c=3&art=34.
Find example uses on this package at http://poocl.la-grotte.org/index.php
Suggestion: If you are NOT writing code to support ALL possible compression/archiving formats, then you can avoid using 'File_Archive'.
Conclusion: Possibilities of extending PHP to support reading/writing files in different compression and file archive formats, were studied.
Advertisement
|