无法打开所需的 'HTTP/Request2.php' (include_path='.;C:\php5\pear')
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4483317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed opening required 'HTTP/Request2.php' (include_path='.;C:\php5\pear')
提问by cj333
everyone. I have some trouble in pear.
I test in my localhost(my localhost path is e:\www
), my system is windows xp sp3, My php version is 5.2.11, the path is C:\Program Files\phpStudy\PHP5
, I run go-pear.bat
in this path and finished install the pear, now the pear path is in C:\Program Files\phpStudy\PHP5\PEAR
(under the folder contains .channels
,.registry
, OS
, PEAR
, .depdb
, .depdblock
, .filemap
, .lock
, go-pear.phar
), then I run C:\Program Files\phpStudy\PHP5\PEAR_ENV.reg
and modify the php.ini,
每个人。我在梨子上遇到了一些麻烦。我在我的本地主机上测试(我的本地主机路径是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"
After restart the apache, I test a simple code which copy from pear's website.
重启apache后,我测试了一个简单的代码,从梨的网站复制。
<?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();
}
?>
but it return
但它回来了
Warning: require_once(HTTP/Request2.php) [function.require-once]: failed to open stream: No such file or directory in E:\www\ct.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.php on line 2
What's wrong is it? How to solve? Thanks.
怎么了?怎么解决?谢谢。
回答by Night Owl
You need to install the PEAR package http_request2.
您需要安装 PEAR 包 http_request2。
You can try the command...
你可以试试命令...
pear install http_request2
as supplied by cweiske but it may fail with an error like...
由 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"
If you see that error you will need to install with the command...
如果您看到该错误,则需要使用以下命令进行安装...
pear install "channel://pear.php.net/http_request2-0.5.2"
This may generate a dependency error regarding the Net_URL2 package like....
这可能会生成有关 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)
If you see such an error issue the command...
如果您看到这样的错误,请发出命令...
pear install "channel://pear.php.net/Net_URL2-0.3.1"
and then re-issue the command...
然后重新发出命令...
pear install "channel://pear.php.net/http_request2-0.5.2"
and you should be all set. The "state" of these packages may change over time so the exact versions in the commands above will also likely change and at some point the command pear install http_request2 may begin working on its own.
你应该准备好了。这些包的“状态”可能会随着时间的推移而改变,因此上述命令中的确切版本也可能会发生变化,并且在某个时候命令 pear install http_request2 可能会开始自行工作。
Good luck.
祝你好运。
回答by cweiske
You need to install the HTTP_Request2 package from pear:
你需要从 pear 安装 HTTP_Request2 包:
pear install http_request2
Then it should work.
那么它应该工作。
回答by Ashy saini
I had similar problem on centos. If above things don't work, follow this patch
我在centos上遇到了类似的问题。如果上述事情不起作用,请遵循此补丁
http://www.angeloluput.com/php-planet/pear-on-php-5-5-could-not-extract-package-xml
http://www.angeloluput.com/php-planet/pear-on-php-5-5-could-not-extract-package-xml
Patch was not working so I have to manually apply the patch. and it worked.
补丁不起作用,所以我必须手动应用补丁。它奏效了。