Skip to content

buzzvshttpful

MIT 11 2 1,919
5.6 thousand (month) Nov 11 2011 1.2.1(2 years ago)
1,738 4 89 MIT
Apr 14 2012 4.7 thousand (month) 1.0.0(2 months ago)

Buzz is a lightweight PHP library for issuing HTTP requests. It is built on top of the PHP curl extension and is designed to be easy to use and flexible.

While buzz isn't as feature rich as other clients it still supports http2 and is relatively easy to use.

Httpful is a simple Http Client library for PHP 7.2+. There is an emphasis of readability, simplicity, and flexibility – basically provide the features and flexibility to get the job done and make those features really easy to use.

Features

  • Readable HTTP Method Support (GET, PUT, POST, DELETE, HEAD, PATCH and OPTIONS)
  • Custom Headers
  • Automatic "Smart" Parsing
  • Automatic Payload Serialization
  • Basic Auth
  • Client Side Certificate Auth
  • Request "Templates"

Highlights


http2uses-curl

Example Use


use Buzz\Client\Curl;
use Buzz\Message\Request;
use Buzz\Message\Response;

$client = new Curl();
// GET request
$request = new Request('GET', 'http://httpbin.org/get');
$response = new Response();
$client->send($request, $response);
echo $response->getContent();

//POST request
$request = new Request('POST', '/api/resource', 'http://example.com');
$request->setContent(json_encode(['name' => 'John Doe']));
// we can also add headers or cookies:
$request->addHeader('Content-Type: application/json');
$request->addHeader('Cookie: name=foobar');
$response = new Response();
$client->send($request, $response);
echo $response->getContent();

// Buzz also supports http2 (see the 2.0 parameter)
$response = $client->sendRequest(
  new Request('GET', 'https://http2.golang.org/serverpush', [], null, '2.0')
);
require 'vendor/autoload.php';

use Httpful\Request;

// make GET request
$response = \Httpful\Request::get("http://httpbin.org/get")
    ->send();
echo $response->body;

// make POST request
$data = array('name' => 'Bob', 'age' => 35);
$response = \Httpful\Request::post("http://httpbin.org/post")
    ->sendsJson()
    ->body(json_encode($data))
    ->send();
echo $response->body;

// add headers or cookies
$response = \Httpful\Request::get("http://httpbin.org/headers")
    ->addHeader("API-KEY", "mykey")
    ->addHeader("Cookie", "foo=bar")
    ->send();
echo $response->body;

Alternatives / Similar


Was this page helpful?