dspacelabs / http-message
PSR-7 Library
Installs: 706
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/dspacelabs/http-message
Requires
- psr/http-message: ^1.0
Requires (Dev)
- phing/phing: ^2.16
- phpunit/phpunit: ^6.2
This package is not auto-updated.
Last update: 2023-11-22 13:37:53 UTC
README
This is a simple, very basic implementation of the PSR-7 standard. This library does not come with a client and only deals with the messages.
Installation
composer require dspacelabs/http-message
Examples
Creating URIs
use Dspacelabs\Component\Http\Message\Uri; $uri = (new Uri()) ->withScheme('http') ->withHost('www.example.com');
If you want something less verbose, you can also pass in the URL when creating new Uri objects.
use Dspacelabs\Component\Http\Message\Uri; $uri = new Uri('http://www.example.com');
Creating Requests
use Dspacelabs\Component\Http\Message\Uri; use Dspacelabs\Component\Http\Message\Request; $request = new Request(); $request ->withMethod('GET') ->withUri(new Uri('http://www.example.com'));
Creating Responses
use Dspacelabs\Component\Http\Message\Response; $resposne = new Response(); $response ->withStatus(200, 'OK');
Testing
Testing is done with PHPUnit and Phing. Once you make updates, run the command
./vendor/bin/phing
And this will run PHPUnit and give you test results.