First I installed the curl extension for PHP:

$ sudo pacman -S php-curl


$ grep curl /etc/php/php.ini

Then I installed the PHP PEAR

$ sudo pacman -S php-pear

Having now installed pear, I have also installed PECL, and should now be able to install the php_http extension.

$ pecl install php_http


$ grep http.so /etc/php/php.ini

The http.so is found in the folder /usr/lib/php/moduels/ and latter copied to the folder /usr/lib/http/modules/ .

Now, as far as I know, this should have installed the php_http extension, but when I try to

$req = new HttpRequest();

I get the error

Fatal error: Class 'HttpRequest' not found in /srv/http/webcrawler/nettocrawl.php on line 4 


The latest version of pecl_http introduces the http namespace. so HttpRequest will no longer be available. Follow php's documentation for using namespace, and checkout the supplied phpunit directory for usage & examples.

$req = new http\Client\Request();

Or a more preferred way, that allows for backwards support

use http\Client\Request as HttpRequest;
$req = new HttpRequest();


Sometimes PECL extensions might not get installed correctly. This can happen if your mixing pacman packages and pecl extensions, but it's very rare. I recommend installing pecl_http by hand.

Grab source

shell ~> curl -o pecl_http.tar.gz http://pecl.php.net/get/pecl_http
shell ~> tar zvxf pecl_http.tar.gz
shell ~> cd pecl_http

Configure, Compile, and Test

shell ~/pecl_http> phpize
shell ~/pecl_http> ./configure
shell ~/pecl_http> make
shell ~/pecl_http> make test


shell ~/pecl_http> make install

This will output the directory http.so will be installed. In my case, it's /usr/lib/php/<timestamp>/. A helpful note.

php.ini & Test

Edit php.ini file, and add the http.so extension.

shell ~> php -m | grep http

If http is not displayed, re-edit the php.ini, and the extensions full path;

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.