大家.我在梨方面遇到了一些麻烦.我测试在我的localhost(我的localhost路径是e:\www),我的系统是windows xp sp3,我的php版本是5.2.11,路径是C:\Program Files\phpStudy\PHP5,我go-pear.bat在这条路径中运行并完成安装梨,现在梨路径在C:\Program Files\phpStudy\PHP5\PEAR(下)该文件夹包含.channels,.registry,OS,PEAR,.depdb,.depdblock,.filemap,.lock,go-pear.phar),然后我运行C:\Program Files\phpStudy\PHP5\PEAR_ENV.reg,并修改php.ini,
; Windows: "\path1;\path2"
include_path = ".;C:\Program Files\phpStudy\PHP5\PEAR"
Run Code Online (Sandbox Code Playgroud)
重新启动apache之后,我测试了一个从pear的网站上复制的简单代码.
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2('http://pear.php.net/', HTTP_Request2::METHOD_GET);
try {
$response = $request->send();
if (200 == $response->getStatus()) {
echo $response->getBody();
} else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
} catch (HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
Run Code Online (Sandbox Code Playgroud)
但它又回来了
Warning: require_once(HTTP/Request2.php) [function.require-once]: failed to open stream: No such file or directory in E:\www\ct\1.php on line 2
Fatal error: require_once() [function.require]: Failed opening required 'HTTP/Request2.php' (include_path='.;C:\php5\pear') in E:\www\ct\1.php on line 2
Run Code Online (Sandbox Code Playgroud)
这有什么不对?怎么解决?谢谢.
Nig*_*Owl 25
您需要安装PEAR包http_request2.
你可以尝试命令......
pear install http_request2
Run Code Online (Sandbox Code Playgroud)
由cweiske提供,但它可能会失败,如...
Failed to download pear/http_request2 within preferred state
"stable", latest release is version 0.5.2, stability "alpha",
use "channel://pear.php.net/http_request2-0.5.2"
Run Code Online (Sandbox Code Playgroud)
如果您看到该错误,则需要使用命令进行安装...
pear install "channel://pear.php.net/http_request2-0.5.2"
Run Code Online (Sandbox Code Playgroud)
这可能会产生关于Net_URL2包的依赖性错误,如....
Failed to download pear/Net_URL2 within preferred state "stable", latest
release is version 0.3.1, stability "beta",
use "channel://pear.php.net/Net_URL2-0.3.1" to install
pear/HTTP_Request2 requires package "pear/Net_URL2" (version >= 0.2.0)
Run Code Online (Sandbox Code Playgroud)
如果你看到这样的错误发出命令......
pear install "channel://pear.php.net/Net_URL2-0.3.1"
Run Code Online (Sandbox Code Playgroud)
然后重新发出命令......
pear install "channel://pear.php.net/http_request2-0.5.2"
Run Code Online (Sandbox Code Playgroud)
你应该全力以赴.这些软件包的"状态"可能会随着时间的推移而发生变化,因此上述命令中的确切版本也可能会发生变化,并且在某些时候,命令pear install http_request2可能会自行开始工作.
祝好运.
| 归档时间: |
|
| 查看次数: |
26903 次 |
| 最近记录: |