Http
![Software License][ico-license]
![Coverage Status][ico-scrutinizer]
![Total Downloads][ico-downloads], (*1)
This is a Work In Progress., (*2)
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, (*3)
Install
Via Composer, (*4)
``` bash
$ composer require codejet/http, (*5)
## Usage
### Uri
Using the Uri class itself.
``` php
$uri = new CodeJet\Http\Uri('https://www.example.com');
echo $uri;
Or, using the http-interop proposed factory., (*6)
``` php
$uri = new CodeJet\Http\Factory\UriFactory('https://www.example.com');
echo $uri;, (*7)
### Request
Creating a request using the PSR7 RequestInterface methods.
``` php
$request = (new CodeJet\Http\Request())->withMethod('POST')->withUri($uri);
echo $uri;
Stream
Using the class constructor., (*8)
``` php
$handle = fopen('php://input','r');
$stream = new CodeJet\Http\Stream($handle);, (*9)
Or, using the [http-interop proposed StreamFactory](https://github.com/http-interop/http-factory).
From a string:
``` php
$string = "I love lamp.";
$stream = (new CodeJet\Http\Factory\StreamFactory())->createStream($string);
From a file:
``` php
$stream = (new CodeJet\Http\Factory\StreamFactory())->createStreamFromFile('php://input', 'r');, (*10)
From a resource handle:
``` php
$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., (*11)
Testing
bash
$ composer test
, (*12)
Contributing
Please see CONTRIBUTING for details., (*13)
Security
If you discover any security related issues, please email josh@findsomehelp.com instead of using the issue tracker., (*14)
License
The MIT License (MIT). Please see License File for more information., (*15)