Create ZIP archives with PHP script and PEAR class

We can use PEAR to process zip files in PHP using Archive_Zip….

First set PEAR path in php include path using set_include_path

Make Zipped file

include (‘Archive/Zip.php’);        // include PEAR ZIP package

$obj = new Archive_Zip(‘’);  // zipped file name

$files = array(‘svnlabs/1.gif’,
svnlabs/invoice.xls’);   // files add to zip

if ($obj->create($files)) {
echo ‘Files zipped successfully!’;
} else {
echo ‘Error in file zipping’;
List Zip file elements

include (‘Archive/Zip.php’);        // include PEAR ZIP package

$obj = new Archive_Zip(‘’); // Input zip file

$files = $obj->listContent();       // zip information

foreach ($files as $f) {
foreach ($f as $s => $v) {
echo “$s: $v\r\n”;
echo “\r\n”;
I really enjoyed programming with PEAR…

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch