Skip to main content

Fun with PECL Zip 1.6 - Installation

With PECL Zip you can read, add, delete, set and read archive comment, it's a very useful package for searching and managing Zipped archive kind of data.
let's begin with the installation
fire up your PECL installer to install Zip; you'll see some information verbosed while installed PECL Zip like the following

wget && tar -zxvf zip && cd zip-1.6.0/ && phpize5 && sudo ./configure && sudo make && sudo make install

During the installation you will be flooded with verbosed information ; it's useful to watch and try to understand what's going behind the scene; keep your eye on the verbose to see if any error popup like missing library or permission problem, if the installation went fine; at the end you will see

Installing shared extensions: /usr/lib/php5/20050922/

Now let's edit php.ini

sudo vim /etc/php5/apache2/php.ini

and add
now you will only need to restart apache to get the new extension loaded

sudo /etc/init.d/apache2 restart

Now ZIP extension are installed so let's explore the examples directory where you will see PHP code example of how to use ZIP extension

First let's see what methods ZIP class have

< ?php
$Zip = New ZipArchive();
print '



This will output

Array (
[0] => open [1] => close
[2] => addFromString [3] => addFile
[4] => renameIndex [5] => renameName
[6] => setArchiveComment [7] => getArchiveComment
[8] => setCommentIndex [9] => setCommentName
[10] => getCommentIndex [11] => getCommentName
[12] => deleteIndex [13] => deleteName
[14] => statName [15] => statIndex
[16] => locateName [17] => getNameIndex
[18] => unchangeArchive [19] => unchangeAll
[20] => unchangeIndex [21] => unchangeName
[22] => extractTo [23] => getFromName
[24] => getFromIndex [25] => getStream )

Most of methods and functions are being used in the example folder of Zip extention

comment.php create.php dir.php extractAll.php extract.php fopen.php get_set_comments.php odt.php oldapi.php too.php



  1. PECL Zip page

  2. Zip documentation at

  3. PECL Zip - new features announcement

[tags] PHP, PECL, Zip [/tags]


  1. That was really cool :)

  2. You don't need zzlib to install pecl/zip, neither with the upcoming PHP 5.2.0. The extension does not use any external library :)

  3. Thanks for correction dude, I must were drunk while compiling it :D


Post a Comment

Popular posts from this blog

اهم التطورات العلمية في العام ٢٠١٩

10 things Dorothée Loorbach learned after losing a lot of money

Dorothée isn't just sharing her life changing experience with work and money, and sharing the following tips which won't make much sense without listening to the tips in her own words Money is important Money equals time Money equals value What people say doesn't matter What people say matters most when people is you! It's really simple - spend less, earn more, invest wisely and value yourself. It's not that easy Being broke sucks Stay Broke - be present in your own life Money isn't important

Rules of war (in a nutshell) Since the beginning, humans have resorted to violence as a way to settle disagreements. Yet through the ages, people from around the world have tried to limit the brutality of war. It was this humanitarian spirit that led to the First Geneva Convention of 1864, and to the birth of modern International Humanitarian Law. Setting the basic limits on how wars can be fought, these universal laws of war protect those not fighting, as well as those no longer able to. To do this, a distinction must always be made between who or what may be attacked, and who or what must be spared and protected.