2017 © Pedro Peláez
 

library http-wrapper

An HTTP wraper library

image

marcoazn89/http-wrapper

An HTTP wraper library

  • Thursday, September 1, 2016
  • by marcoazn89
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5,071 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 19 % Grown

The README.md

Install via Composer

composer require marcoazn89/http-wrapper:dev-dev

Features

  • PSR-7 compliant response object
  • Content negotiation
  • Constants to avoid mistyping
  • Flexibility to use outside of PSR-7

Create a new response object

require '../vendor/autoload.php';

$response = new \HTTP\Response();

Set headers

require '../vendor/autoload.php';

(new \HTTP\Response())->withType(\HTTP\Response\ContentType::JSON)
->write(['greeting' => 'Hello World'])->send();

Negotiate Headers

require '../vendor/autoload.php';

//Assuming the client send Accept:text/plain
(new \HTTP\Response())->withTypeNegotiation()->write("Test")->send();

Set limits on what you can support

The order in which you add support matters! This will ignore any Accept headers that don't match the supported types. ```php require '../vendor/autoload.php';, (*1)

use HTTP\Support\TypeSupport; use HTTP\Response\ContentType;, (*2)

// Add content you can support TypeSupport::addSupport([ ContentType::HTML, ContentType::XML ]);, (*3)

// Assume the client sent XML as the accept header, the following output will be // in XML form because it was the best match in the supported types (new \HTTP\Response())->withTypeNegotiation()->write(", (*4)

Hello World, (*5)

")->send();, (*6)

The Versions

01/09 2016

dev-master

9999999-dev https://github.com/marcoazn89/http-wrapper

An HTTP wraper library

  Sources   Download

MIT

The Requires

 

The Development Requires

php library http

01/09 2016

v2.1.1

2.1.1.0 https://github.com/marcoazn89/http-wrapper

An HTTP wraper library

  Sources   Download

MIT

The Requires

 

The Development Requires

php library http

27/04 2016

v2.1.0

2.1.0.0 https://github.com/marcoazn89/http-wrapper

An HTTP wraper library

  Sources   Download

MIT

The Requires

 

The Development Requires

php library http

12/03 2016

v2.0

2.0.0.0 https://github.com/marcoazn89/http-wrapper

An HTTP wraper library

  Sources   Download

MIT

The Requires

 

The Development Requires

php library http

09/03 2016

v1.0

1.0.0.0 https://github.com/marcoazn89/http-wrapper

An HTTP wraper library

  Sources   Download

MIT

The Requires

 

php library http