OhHttp is a HTTP Request and Response library for PHP

1.0.1 2015-08-17 16:03 UTC

This package is auto-updated.

Last update: 2024-10-16 01:15:47 UTC


README

OhHttp is a HTTP Request and Response library for PHP

Latest Stable Version Total Downloads Latest Unstable Version License Build Status

Using Composer

To use OhHttp with Composer, add the dependency (and version constraint) to your require block inside your composer.json file.

{
    "require": {
        "rogerthomas84/ohhttp": "1.0.*"
    }
}

Quick Start

You can use the \OhHttp\Request and \OhHttp\Response to provide a simplified HTTP Request and Response, but moving towards a more OO approach.

Request

$request = new \OhHttp\Request();
if ($request->isGet()) {
    $userId = $request->getParam('id', null);
    // do something
} elseif ($request->isPost()) {
    $userId = $request->getParam('id', null);
    // do something
}

Response

$response = new \OhHttp\Response();
$response->setHeader('Content-Type', 'application/json');
$response->setBody('{"foo":"bar"}');
$response->send();