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 http://pecl.php.net/get/zip && 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
extension=zip.so
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 '
<
pre>'.print_r(get_class_methods($Zip)).'';

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 test1.zip test_with_comment.zip test.zip too.php

Enjoy
Resources

  1. PECL Zip page

  2. Zip documentation at PHP.net

  3. PECL Zip - new features announcement


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

Comments

  1. That was really cool :)

    ReplyDelete
  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 :)

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

    ReplyDelete

Post a Comment

Popular posts from this blog

Zend PHP 5 Certification Voucher *sheesh* DISCOUNT

In 2005 we had great discount from Zend for the PHP4 exam voucher, guide and practice book, This year, couple of months ago we at JoPHP (Jordan PHP Users Group) for PHP5 Exam festival, we had plan to do one week exam preparation session and then twenty five of us was motivated to take the exam. Many things slowed down the plan and killed the motive and I guess you are safe to put it on me and blame me for that; Hope we will be able to prepare for another event later in 2007. But anyway we always have B plan and here is the deal Purchase PHP 5 Certification Guide which is available in PDF format Practice for the exam Purchase the Certification voucher and use this zcej100 discount code to get $25 off your order. When you feel comfortable, Schedule your test and take the exam Big thanks for Zend for their generous offer and hope we can make better plan for such event next year. Wish you the best. [tags] php users, zend, voucher, users group, many things, motive, jordan, certif

?????? ?????

?????, ?????, ????? ??? ???? ?????! ?? ????? ??????? ???, ??? ?? ???? ?? ?????? ??? ???? ?? ???? ??? ???? ?? ??? ???? ???? , ???? ???? ????? ???????, ????????, ???? ???????, ???? ? ???? ? ???? ????? ???? ????? ??????, ?????? ???? ?? ????? ?????? ???? ????? ??? ??????? ?? ????? ? ??? ?? ??????? ???????? ?? ???? ?? ????? ???? ????? ??? ?????? ? ???? ?????? ????? ? ???? ????? ?????? ???? ?????? ???? ???? ????? ? ???????? ???? ???????, ??? ?????? ????? ?? ??? ????? ?????? ??? ??????? ??? ??? ??????? ????? ???? ? ???? ????? ??? ???? ??? ???? ???? ??????, ?? ????? ??? ?????? ???????? ??? ?????? ?? ??? ???? ???? ?? ??, ???? ???? ??? ?? ????? ?????? ??????

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