Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

First I installed the curl extension for PHP:

$ sudo pacman -S php-curl

and

$ grep curl /etc/php/php.ini
extension=curl.so

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

and

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

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 
share|improve this question
    
Looks like HTTP_Request has its own pear package. Is it installed already? –  Stéphane Gimenez Aug 17 '11 at 14:30

1 Answer 1

up vote 1 down vote accepted

PECL HTTP 2.0+

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();

Else

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

Install

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;

extension=/usr/lib/php/<timestamp>/http.so
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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