After I “upgraded” Fedora (to Fedora 19) on my main PC recently, I only had one other essential post-installation task to complete before I could get back to my regular programming on this machine. I just had to install the pecl_http
PHP extension next.
This time, however, I didn’t have to install it “manually” like I used to do on quite a few occasions before. Nowadays, things are a lot different – the pecl_http
PHP extension is now available as a neat little package in the main Fedora repository and can be easily installed via the Yum Package Manager with just one simple command:
sudo yum install php-pecl-http*
As soon as the software was successfully installed and the whole task out of the way, I excitedly tested my web page with PHP script that included code that required the pecl_http
PHP extension. Every request of the web page was simply returned as a 500 Server Error! I was thoroughly confused and here’s what going through the error log revealed:
... .. PHP Fatal error: Class 'HttpResponse' not found in /home/mememe/domains/gidapp.com/public_html/4/example.php on line 54, referer: http://www.gidapp.lan/
What I really didn’t notice until just now is that there are 2 versions of the pecl_http
PHP extension! Who knew?
[[email protected] tmp]$ sudo yum info php-pecl-http ... Name : php-pecl-http Arch : i686 Version : 2.0.0 Release : 0.16.beta4.fc19 Size : 254 k Repo : fedora/19/i386 Summary : Extended HTTP support URL : http://pecl.php.net/package/pecl_http License : BSD Description : The HTTP extension aims to provide a convenient and powerful set of : functionality for major applications. : : The HTTP extension eases handling of HTTP URLs, dates, redirects, headers : and messages in a HTTP context (both incoming and outgoing). It also provides : means for client negotiation of preferred language and charset, as well as : a convenient way to exchange arbitrary data with caching and resuming : capabilities. : : Also provided is a powerful request and parallel interface. : : Version 2 is completely incompatible to previous version. : : Documentation : http://php.net/http
What I had installed on all my other computers before and what I have been using up until today was pecl_http version 1+
. What is installed on my remote web servers is also pecl_http version 1+
. What I had installed on my main PC today, however, was pecl_http version 2
! And guess what else? The 2 versions are completely incompatible with each other! In other words, pecl_http
PHP extension version 2 does not even have a class named HttpResponse
anymore, which explains the error report.
From the official documentation for pecl_http
version 2:
This is to become v2 of the known pecl_http extension.
It is completely incompatible to previous version.
Emphasis mine.
After confirmation from an expert, I uninstalled the software right away:
sudo yum remove php-pecl-http
And re-installed the pecl_http
PHP extension version 1+ the old-fashioned way.