rogerthomas84 / ohhttp
OhHttp is a HTTP Request and Response library for PHP
Installs: 10 152
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=5.3.7
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
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();