https://github.com/dspacelabs/http-message
Simple PSR-7 Implementation
https://github.com/dspacelabs/http-message
http-server php psr-7
Last synced: about 1 month ago
JSON representation
Simple PSR-7 Implementation
- Host: GitHub
- URL: https://github.com/dspacelabs/http-message
- Owner: dSpaceLabs
- License: mit
- Created: 2017-06-17T22:49:29.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-27T03:35:22.000Z (almost 8 years ago)
- Last Synced: 2025-03-22T07:48:31.058Z (about 1 month ago)
- Topics: http-server, php, psr-7
- Language: PHP
- Homepage:
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
dspacelabs/http-message [](https://travis-ci.org/dSpaceLabs/http-message)
=======================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
```bash
composer require dspacelabs/http-message
```## Examples
### Creating URIs
```php
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.```php
use Dspacelabs\Component\Http\Message\Uri;$uri = new Uri('http://www.example.com');
```### Creating Requests
```php
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
```php
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
```bash
./vendor/bin/phing
```And this will run PHPUnit and give you test results.