2010-12-19 105 views
13

everyone。我在梨上遇到了一些麻烦。我的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.registryOSPEAR.depdb.depdblock.filemap.lockgo-pear.phar),然后我跑C:\Program Files\phpStudy\PHP5\PEAR_ENV.reg和修改php.ini,无法打开所需的'HTTP/Request2.php'(include_path ='.; C: php5 pear')

; Windows: "\path1;\path2" 
include_path = ".;C:\Program Files\phpStudy\PHP5\PEAR" 

重新启动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(); 
} 
?> 

但它返回

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 

有什么不对呢?怎么解决?谢谢。

+0

你缺少文件e:\ www \ HTTP \ Request2.php – 2010-12-19 18:13:56

回答

25

您需要安装PEAR软件包http_request2。

您可以尝试命令

pear install http_request2 

由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" 

如果您发现错误,你将需要用命令安装...

pear install "channel://pear.php.net/http_request2-0.5.2" 

这可能会产生一个关于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) 

如果你看到这样的错误问题命令

pear install "channel://pear.php.net/Net_URL2-0.3.1" 

,然后重新发出命令

pear install "channel://pear.php.net/http_request2-0.5.2" 

,你应该准备就绪。这些软件包的“状态”可能会随着时间而改变,所以上述命令中的确切版本也可能会发生变化,并且在某些时候,梨安装http_request2的命令可能会自行开始工作。

祝你好运。

+0

这个问题占了我很长一段时间,现在它的工作,谢谢'夜猫子' – cj333 2011-02-14 17:35:12

+0

感谢您的答案。它帮助我解决了我在使用Pear在Ubuntu上安装PHPUnit时遇到的一个问题。Natty – Steven 2011-07-06 02:13:58

+0

最优秀的,尤其是使用'pear install“通道的提示......工作过一段时间。 – 2012-07-16 15:30:36

1

您需要从梨安装HTTP_Request2包:

pear install http_request2 

那么它应该工作。