Re: Question about PECL Zip package
| From: | Martin Jorgensen | Date: | Thu, 18 Dec 2003 09:56:00 +0000 |
| Subject: | Re: Question about PECL Zip package | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9646@lists.php.net to get a copy of this message | ||
"Michael Wallner" <mike@php.net> wrote in message
news:20031218093207.58798.qmail@pb1.pair.com...
Hi Martin Jorgensen, you wrote:
> This is what I see when I type 'pear list'
>
[...]
> XML_Parser 1.0.1 stable
> XML_RPC 1.0.4 stable
> zip 1.0 stable
>
> This should indicate that the zip package is installed.
This only idicates for PEAR that zip is installed.
>
> When my script executes, I don't get any error messages. The
> PEAR::loadExtension('zip'); just doesn't do anything, i.e. - I can't get
all
> the zip functions to work.
PEAR::loadExtension() just returns boolean.
What's about:
<?php error_reporting(E_ALL); dl('zip.so'); ?>
------
This returns:
Warning: dl(): Unable to load dynamic library './zip.so' - ./zip.so: cannot
open shared object file: No such file or directory in...
--------
> I'd like to see an example of a PHP script that makes use of PEAR's zip
> package - just to see if I'm missing something!
You can find a small file attached which extracts images from
an ZIP archive.
> Thanks a LOT for your help.
First locate your extension dir:
$ php -i | grep extension_dir
and check if it is the same as PEARs:
$ pear config-show | grep ext_dir
Then ensure that zip.so is in this path, otherwise
locate where PEAR has installed zip.so:
$ find / -name zip\.so
--- output on my box ---
mike@s1-iw:~$ php -i | grep extension_dir
extension_dir => /usr/lib/php/20020429 => /usr/lib/php/20020429
mike@s1-iw:~$ pear config-show | grep ext_dir
PHP extension directory ext_dir /usr/lib/php/20020429
Output on mine:
root@server [~]# php -i | grep extension_dir
extension_dir => ./ => ./
root@server [~]# pear config-show | grep ext_dir
Binary file (standard input) matches
root@server [~]# find / -name zip\.so
/usr/local/lib/php/extensions/zip.so
There in lies my problem it seems. Any way I can correct this ?
Thanks a lot for taking your time to help. It's highly appreciated.
Regards,
Martin.
--- ### ---
Regards,
--
Michael - < mike(@)php.net >
* @copyright IWORKS 2003 * @link http://iworks.at/ * @version 0.1 */
require_once('PEAR.php'); require_once('VIF_Image.php'); class VIF_ImagePack
extends PEAR { var $_date; var $_file; var $_zip_handle; /** * Constructor *
* @access public * @return object */ function VIF_ImagePack($zip = '') {
$this->_date = date('Y-m-d_h-i-s'); $this->_file = $zip; $this->PEAR(); }
/** * Destructor * * @access private * @return void */ function
_VIF_ImagePack() { @zip_close($this->_zip_handle); unlink($this->_file);
$this->_PEAR(); } /** * Set file path * * @access public * @return mixed */
function setFile($zip) { $this->_file = $zip; } /** * Get an image * *
@access public * @return mixed */ function &getImage() { if
(!$this->_open()) { return false; } $entry = @zip_read($this->_zip_handle);
if (!is_resource($entry)) { return false; } if
(!@zip_entry_open($this->_zip_handle, $entry, 'rb')) { return false; }
$image = zip_entry_read($entry, zip_entry_filesize($entry));
zip_entry_close($entry); return new VIF_Image($image, $this->_date); } /** *
Open the zip file * * @access private * @return mixed */ function _open()
{ static $already_tried_to_open; if (!is_file($this->_file)) { return
false; } if (!$already_tried_to_open) { $this->_zip_handle =
@zip_open($this->_file); $already_tried_to_open = true; } if
(!is_resource($this->_zip_handle)) { return false; } return true; } } ?>