HttpRequest not found in php HttpRequest not found in php php php

HttpRequest not found in php


If you are using php 5.4 or above, there does not seem to be a php_http.dll file to include in your extensions library (Unless someone can find one that I missed??).

The only one that I could find generated errors on starting up the Apache server after updating the php.ini configuration file to include the extension.

Fear not however, as there seems to be a GitHub Project which provides the functionality within a class, rather than an extension. Click here to find the required class.

If you save this class in your project and call like so;

include_once('HttpRequest.php'); //where HttpRequest.php is the saved file$url= 'http://www.google.com/';$r = new HttpRequest($url, "POST");var_dump($r->send());

Failing that, it would seem that the only other viable option would be to compile the .dll yourself from the source here :(

Otherwise, another option would be to use cURL instead. cURL provides most (if not all) of the functionality of the httpRequest.

A simple example of this would be;

$url = "http://www.google.com/";        $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_NOBODY, TRUE); // remove body $head = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); var_dump($head);

More details and better examples can be found on the php website Here

I hope this helps answer your question, rather than leave you with more...


You need to make sure you have a php_http.dll that matches your PHP version. You can do <?php phpinfo(); to check with extensions are loaded (look for "http", it will list the version and available classes).

If the extension does not appear in phpinfo(), you should check your logs to learn where the problem comes from or run the PHP binary directly from the command prompt — php -i. If there is any error loading a dynamic library it will show up in a dialog box. Note that PHP will still continue to function even though an extension failed to load.


you can reinstall the package

$ pecl install -f pecl_http-1.7.6

or access the data using curl like this snippet