Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP PECL_HTTP vs cURL Extension

Tags:

http

php

curl

pecl

I'm working on a PHP Client for CouchDB. While browsing through the php.net documentation regarding HTTP and cURL, I came across the PECL_HTTP Extension. At first glance, I think I would like to use this PECL extension instead of cURL because it's much simpler to use, and I'm not doing very complicated HTTP work anyways. Plus I always like trying new things, so I wouldn't mind getting my feet wet.

As far as my question to the StackOverflow community:

  • Has anyone used both the PECL_HTTP and cURL extensions?
  • Does the PECL extension have any serious performance issues?
  • Is the PECL extension as user-friendly as it appears on the surface?
  • Is the tried-and-true cURL library still superior?

Edit: As it turns out, the PECL_HTTP extension uses some of the cURL source code under the hood, so they aren't completely different beasts. Both are also compiled extensions to PHP.

like image 315
Dominic Barnes Avatar asked Jan 16 '10 00:01

Dominic Barnes


3 Answers

In my opinion CURL is straightforward and easy to pick up. In PHP Cookbook (O'Reilly, 2002) CURL was chosen for various (performance) reasons.

like image 66
Heiko Avatar answered Nov 17 '22 03:11

Heiko


The PECL_HTTP extension has proven much simpler to use, almost cutting my code in half in some places. :)

like image 39
Dominic Barnes Avatar answered Nov 17 '22 03:11

Dominic Barnes


At first I have to say we used both at our company and from the handling I like php_http more and I appreciate the work of Mike.

But we abandoned php_http because it is not bundled in vanilla php. We are working in a windows environment and for each pecl extension which is not bundled by php itself, we have to compile it ourselves (which is not a bad thing). While compiling we got an error that some headers were missing. It turned out it was totally our fault, because it's clearly stated in the documentation.

And the since version 2.0 of php_http, it has two none-standard dependancies: - raphf 1.0.0 or newer - propro 1.0.0 or newer

So we needed to compile more than only php_http. But for propro 1.0.0 (2013-08-12) config.w32 was missing in the download (at least in the state of writing). So we had to write our own one. And so on...

In the end we got it working for PHP 5.5 VC11 x86, but it took some time. In companies you sometimes doesn't have time to spend on such things. Curl always works out of the box, because it's bundled. This might be a serious reason not to use php_http.

Something I would really appreciate is if php_http would do it into vanilla php.

Hope this helps some decision makers ;-)

like image 2
McK Avatar answered Nov 17 '22 02:11

McK