codejet / http
PSR7 http-messages implementation
Requires
- php: ^7.0
- psr/http-message: ^1.0
Requires (Dev)
- http-interop/http-factory-tests: ^0.2
- phpunit/phpunit: ~4.0||~5.0
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-11-29 05:44:33 UTC
README
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.