'Failed opening required 'HTTP/Request2.php' (include_path='.;C:\php5\pear')
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,
; 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.
<?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\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
What's wrong is it? How to solve? Thanks.
Solution 1:[1]
You need to install the HTTP_Request2 package from pear:
pear install http_request2
Then it should work.
Solution 2:[2]
I had similar problem on centos. If above things don't work, follow this patch
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.
Solution 3:[3]
try it with composer
$ composer require pear/http_request2
using Window you may try
php composer.phar require pear/http_request2
with allow all dependencies parameter
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | cweiske |
| Solution 2 | Ashy saini |
| Solution 3 | gacon |
