如何使用梨包?

时间:2010-03-14 23:17:32

标签: php pear

我想使用HTTP_DOWNLOAD来管理我的下载,我之前从未使用过PEAR

HTTP_DOWNLOAD依赖于许多其他软件包,我下载了它们以及它们依赖的软件包,这就是我所做的结构:

Download.PHP    <---HTTP_DOWNLOAD MAIN FILE
Header.php      <--- HTTP_HEADER MAIN FILE
PEAR.php
PEAR5.php         
Type.php        <--- MIME_Type
   >Type        <---- FOLDER
      - Extension.php    MIME_Type File
      - Parameter.php    MIME_Type File

假设Http_DOWNLOAD依赖于:

* PHP 4.2.0
* PEAR 1.4.0b1
* PEAR
* HTTP_Header
* pcre extension
* Archive_Tar (Optional)
* Archive_Zip (Optional)
* MIME_Type (Optional)
* mime_magic extension (Optional)
* pgsql extension (Optional)

我编辑了每个文件中的路径以反映这种结构,我尝试运行以下代码:

<?php
require_once 'Download.php';
$params = array('file'=>'file.zip');
$down = new HTTP_Download($params);
$down->send(true); 
?>
没有任何反应!! 我也很难想到如何使用该类,我认为这段代码应该可以工作..但不确定!

请帮助!

2 个答案:

答案 0 :(得分:2)

如果可以,请使用pear安装程序。这将负责下载相互依赖性并确保它们都被放入适当的目录中。 还要确保正确设置了include_path。

如果正确安装了梨,您应该可以执行以下操作: $梨清单 并获取本地安装的所有软件包的列表。

http://pear.php.net/manual/en/installation.php应该提供帮助

你需要做类似的事情:

$ sudo pear install HTTP_Download
[sudo] password for kguest:
WARNING: channel "pear.php.net" has updated its protocols, use "channel-update pear.php.net" to update
WARNING: "pear/Archive_Zip" is deprecated in favor of "pecl/zip"
Did not download optional dependencies: pear/Archive_Zip, use --alldeps to download automatically
pear/HTTP_Download can optionally use package "pear/Archive_Zip"
downloading HTTP_Download-1.1.3.tgz ...
Starting to download HTTP_Download-1.1.3.tgz (12,054 bytes)
.....done: 12,054 bytes
downloading HTTP_Header-1.2.0.tgz ...
Starting to download HTTP_Header-1.2.0.tgz (10,440 bytes)
...done: 10,440 bytes
install ok: channel://pear.php.net/HTTP_Header-1.2.0
install ok: channel://pear.php.net/HTTP_Download-1.1.3

答案 1 :(得分:-1)

更改require_once函数,使其前置PHP文件夹的路径。像:

  

require_once   '/home/[youraccount]/php/Download.php';