Reputation: 3770
I installed pecl_http extension in windows and I ran the following code:
<?php
$r = new HttpRequest('http://example.com/feed.rss', HttpRequest::METH_GET);
$r->setOptions(array('lastmodified' => filemtime('local.rss')));
$r->addQueryData(array('category' => 3));
try {
$r->send();
if ($r->getResponseCode() == 200) {
file_put_contents('local.rss', $r->getResponseBody());
}
} catch (HttpException $ex) {
echo $ex;
}
?>
I get error as below:
Fatal error: Class 'HttpRequest' not found in C:\xampp\htdocs\web_services\pecl_http.php on line 3
This is how I installed pecl_http:
downloaded and added following lines to php.ini (thread safe vc9)
extension=php_raphf.dll
extension=php_propro.dll
extension=php_http.dll
This is what I get when I run phpinfo() function:
I am using php 5.4.22 (xampp) on windows 8.
Why am I getting this class not found error when I have the pecl extension enabled?
Upvotes: 2
Views: 3214
Reputation: 3770
Well I figured out what was wrong. I installed http version 2 extension which is a complete renovation of version 1. Instead of HttpRequest class, we have http \ Client () class. I got this information from one of the comments on https://www.php.net/manual/en/http.install.php. The documentation for http 2 is at http://devel-m6w6.rhcloud.com/mdref/http/. The documentation lacks example though.
Upvotes: 6