Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Mohammad Emran Hasan:
Concurrent HTTP requests in PHP using pecl_http
Oct 07, 2013 @ 15:42:09

Mohammad Emran Hasan has posted a quick example of using the pecl_http extension to make concurrent HTTP requests.

The pecl_http extension has a little gem that can be handy at times – HttpRequestPool. Using this, you can send concurrent HTTP requests and can gain efficiency in fetching non-related data at once. For example, from an external source if your application needs to retrieve an user’s profile, their order history and current balance, you can send parallel requests to the API and get everything together.

His code shows three example connections to a made up URL on three different endpoints. With the HttpRequestPool functionality, all three can be requested at once and tracked to extract the response body.

tagged: concurrent http request httprequestpool pecl peclhttp extension

Link: http://emranhasan.com/2013/09/concurrent-requests-in-php-using-pecl_http/

Lorna Mitchell's Blog:
Deprecated Methods in Pecl_Http
Oct 28, 2010 @ 15:04:59

In a quick post to her blog Lorna Mitchell mentions a deprecated method in pecl_http that could cause problems for you down the road - addRawPostData.

I'm a big fan of pecl_http, which I use quite often as I work so regularly with APIs and on systems where I can get it installed, it's much nicer than PHP's curl extension. Recently though I've been often seeing output which reads: Function HttpRequest::addRawPostData() is deprecated

The alternative is to use the "setBody()" method on the HttpRequest object instead. This, in effect, does the same thing and sets the contents of the message to the raw data you'd like to post. Unfortunately, the PHP manual page doesn't reflect that this method is deprecated. You can find out more about the functionality the "pecl_http" extension has to offer here. It's a very flexible and reliable way for your scripts to interact with remote servers via HTTP calls.

tagged: httprequest peclhttp extension deprecated addrawpostdata

Link:

Paul Reinheimer's Blog:
Where's it Up?
Jul 23, 2010 @ 15:53:08

In a recent post to his blog Paul Reinheimer talks about a service (from WonderProxy) called Where's it Up? - a tool that can be used to see where in the world a site is up. He also outlines the technology behind it all.

The tool accepts a URL, and allows you to select global locations. It then attempts to connect to the given server and issue a HEAD request from the global locations you selected, and reports the results. [...] Building a reasonably robust application was trivial, thanks to being able to leverage the great technology built by others.

Tools that make up the application's stack include a Gearman server, curl, PHP with the pecl_http extension, memcached and supervisord. He details how they all fit together and why they built it in the first place.

tagged: wheresitup gearman peclhttp curl memcached supervisord tool

Link:

Mike Wallner's Blog:
Introducing libcurls multi socket API
Sep 11, 2007 @ 18:48:44

Mike Wallner has announced the release of the first beta of the pecl_http PECL package, an extension that "aims to provide a convenient and powerful set of functionality for one of PHPs major applications."

So, finally a first beta of pecl_http 1.6 has been released. This is the first version which supports libcurls multi socket API introduced in 7.16 through libevent.

The rest of the post shows stats comparing the timing on a normal connection versus using the multi-socket API (on both an empty file and a 100k file).

tagged: peclhttp libcurl multisocket api pecl package peclhttp libcurl multisocket api pecl package

Link:

Mike Wallner's Blog:
Introducing libcurls multi socket API
Sep 11, 2007 @ 18:48:44

Mike Wallner has announced the release of the first beta of the pecl_http PECL package, an extension that "aims to provide a convenient and powerful set of functionality for one of PHPs major applications."

So, finally a first beta of pecl_http 1.6 has been released. This is the first version which supports libcurls multi socket API introduced in 7.16 through libevent.

The rest of the post shows stats comparing the timing on a normal connection versus using the multi-socket API (on both an empty file and a 100k file).

tagged: peclhttp libcurl multisocket api pecl package peclhttp libcurl multisocket api pecl package

Link:


Trending Topics: