Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommendations for a good PHP HTTP class

Tags:

http

php

For previous projects I have used

/**
 * HTTP Class
 *
 * This is a wrapper HTTP class that uses either cURL or fsockopen to
 * harvest resources from web. This can be used with scripts that need
 * a way to communicate with various APIs who support REST.
 *
 * @author      Md Emran Hasan <[email protected]>
 * @package     HTTP Library
 * @copyright   2007-2008 Md Emran Hasan
 * @link        http://www.phpfour.com/lib/http
 * @since       Version 0.1
 */

This works very well but does not appear to have been updated in quite some time (indeed, the link above does not even work now...).

My latest project is going to make heavy use of http methods (accessing cross domain and internal APIs) so I need to make sure I am using as efficient an http class/library as possible.

What do you use for this functionality?

like image 563
͢bts Avatar asked Dec 28 '22 02:12

͢bts


2 Answers

PHP has a native HTTP class in PECL:

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 (PHP5+), if the extension is built with cURL support.

In addition, most PHP functions able to work with remote resources can be used with custom Stream Contexts, which will allow you to configure how PHP connects to resources.

like image 81
Gordon Avatar answered Jan 03 '23 00:01

Gordon


I typically use Zend_Http_Client unless im working in a Symfony project - in that case i use sfWebBrowserPlugin.

like image 38
prodigitalson Avatar answered Jan 03 '23 00:01

prodigitalson