HomePHP Page 8 - TAR File Management With PHP Archive_Tar
... And Packing Up - PHP
Need to create or manipulate a TAR file through your Web browser? Take a look at the PEAR Archive_Tar class, which exposes a simple, yet extremely powerful, API to perform manipulation of TAR and TGZ archives through a PHP script. Possible applications include a TAR file viewer and a Web-based backup utility.
And that's about it for this tutorial. Over the last few pages, I took you on a whirlwind tour of the Archive_Tar class, one of the more useful items in PEAR's collection of filesystem tools. I showed you the basics of creating a TAR file, adding files to it, viewing its contents, and extracting it to a specific directory.
I also showed you a couple of more advanced tricks, including compressing the archive with either GZIP or BZIP2 compression and using built-in class methods to alter the directory structure of the files within the archive. Finally, I wrapped things up with two examples of how the Archive_Tar class could be used in real Web applications, by building a simple TAR file viewer and a file backup utility.
In case you'd like to read more about the topics discussed in this article, you should consider bookmarking the following sites:
The official Archive_Tar Web page, at http://pear.php.net/package-info.php?pacid=24
The PEAR Web site, at http://pear.php.net/
The GNU TAR pages, at http://www.gnu.org/software/tar/tar.html
The GZIP pages, at http://www.gzip.org/
The BZIP2 pages, at http://www.digistar.com/bzip2/
Until next time...happy archiving!
Note: Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article. YMMV!