codejet/http

PSR7 http-messages implementation

0.0.1 2016-12-30 17:14 UTC

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

This is a Work In Progress.

This is an exercise in understanding the http-interop related standards and is an implementation of PSR-7 HTTP message interfaces and HTTP-Factory Interfaces

Install

Via Composer

$ composer require codejet/http

Usage

Uri

Using the Uri class itself.

$uri = new CodeJet\Http\Uri('https://www.example.com');
echo $uri;

Or, using the http-interop proposed factory.

$uri = new CodeJet\Http\Factory\UriFactory('https://www.example.com');
echo $uri;

Request

Creating a request using the PSR7 RequestInterface methods.

$request = (new CodeJet\Http\Request())->withMethod('POST')->withUri($uri);
echo $uri;

Stream

Using the class constructor.

$handle = fopen('php://input','r');
$stream = new CodeJet\Http\Stream($handle);

Or, using the http-interop proposed StreamFactory.

From a string:

$string = "I love lamp.";
$stream = (new CodeJet\Http\Factory\StreamFactory())->createStream($string);

From a file:

$stream = (new CodeJet\Http\Factory\StreamFactory())->createStreamFromFile('php://input', 'r');

From a resource handle:

$handle = fopen('php://input','r');
$stream = (new CodeJet\Http\Factory\StreamFactory())->createStreamFromResource($handle);

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email josh@findsomehelp.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.