[ACCEPTED]-PHP Difference between Curl and HttpRequest-post

Accepted answer
Score: 26

Curl is bundled with PHP, HTTPRequest is 13 a separate PECL extension.

As such, it's 12 much more likely that CURL will be installed 11 on your target platform, which is pretty 10 much the deciding factor for most projects. I'd 9 only consider using HTTPRequest if you 8 plan to only ever install your software 7 on servers you personally have the ability 6 to install PECL extensions on; if your clients 5 will be doing their own installations, installing 4 PECL extensions is usually out of the question.

This page seems 3 to suggest that HTTPRequest uses CURL under 2 the hood anyway. Sounds like it might offer 1 a slightly more elegant interface to curl_multi_*(), though.

Score: 10

HTTPRequest (and the PECL extension) is 7 built on libcurl.


The HTTPRequest is really 6 just an easier/more syntactically friendly 5 way to perform the same task.

As Frank Farmer 4 mentioned, you're more likely to have a 3 target platform with curl already installed 2 and could have difficulty getting the PECL 1 library installed by the hosting provider.

Score: 5

The HTTPRequest is "kind of" a wrapper for 22 curl. This two quotes from the manual should 21 give you a clue:

  • It provides powerful request 20 functionality, if built with CURL support. Parallel 19 requests are available for PHP 5 and greater.

  • The 18 extension must be built with » libcurl support 17 to enable request functionality (--with-http-curl-requests). A 16 library version equal or greater to v7.12.3 15 is required.

Said that (and said that I've 14 never used this extension myself), looks 13 like if you want your code to look more 12 object oriented, you can go for this one, but 11 it might be a bit slower, though nothing 10 compared with the external call that you 9 are going to make, so I won't consider performance 8 to make my choice. I would give preference 7 to the fact that curl is built in and this 6 other you have to add it yourself, which 5 is unconvenient and reduces portability 4 in case you want to host your app in a shared 3 environment that you don't control.

For the 2 needs that you explained in your question, I 1 would definitely go for curl.

More Related questions