Skip to content

Commit

Permalink
Merge pull request #18 from sunrise-php/release/v2.0.0
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
fenric authored Oct 24, 2021
2 parents e71162d + 884550c commit 5f8159f
Show file tree
Hide file tree
Showing 21 changed files with 662 additions and 613 deletions.
55 changes: 55 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
php71:
docker:
- image: circleci/php:7.1-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php72:
docker:
- image: circleci/php:7.2-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php73:
docker:
- image: circleci/php:7.3-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php74:
docker:
- image: circleci/php:7.4-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php80:
docker:
- image: circleci/php:8.0-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
workflows:
version: 2
build:
jobs:
- php71
- php72
- php73
- php74
- php80
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@ indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
15 changes: 8 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.php_cs.cache
.phpunit.result.cache
composer.lock
coverage.xml
phpcs.xml
phpunit.xml
vendor/
/.php_cs.cache
/.phpunit.result.cache
/composer.lock
/coverage.xml
/phpbench.json
/phpcs.xml
/phpunit.xml
/vendor/
5 changes: 4 additions & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
build:
environment:
php:
version: '8.0'
nodes:
analysis:
tests:
Expand All @@ -7,7 +10,7 @@ build:
coverage:
tests:
override:
- command: php vendor/bin/phpunit --coverage-clover coverage.xml
- command: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-clover coverage.xml
coverage:
file: coverage.xml
format: clover
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

53 changes: 12 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
## HTTP message wrapper for PHP 7.1+ (incl. PHP 8) based on RFC-7230, PSR-7 & PSR-17
# HTTP message wrapper for PHP 7.1+ based on RFC-7230, PSR-7 and PSR-17

[![Gitter](https://badges.gitter.im/sunrise-php/support.png)](https://gitter.im/sunrise-php/support)
[![Build Status](https://scrutinizer-ci.com/g/sunrise-php/http-message/badges/build.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/http-message/build-status/master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sunrise-php/http-message/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/http-message/?branch=master)
[![Build Status](https://circleci.com/gh/sunrise-php/http-message.svg?style=shield)](https://circleci.com/gh/sunrise-php/http-message)
[![Code Coverage](https://scrutinizer-ci.com/g/sunrise-php/http-message/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/http-message/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/sunrise/http-message/v/stable)](https://packagist.org/packages/sunrise/http-message)
[![Total Downloads](https://poser.pugx.org/sunrise/http-message/downloads)](https://packagist.org/packages/sunrise/http-message)
[![License](https://poser.pugx.org/sunrise/http-message/license)](https://packagist.org/packages/sunrise/http-message)

## Awards
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sunrise-php/http-message/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/http-message/?branch=master)
[![Total Downloads](https://poser.pugx.org/sunrise/http-message/downloads?format=flat)](https://packagist.org/packages/sunrise/http-message)
[![Latest Stable Version](https://poser.pugx.org/sunrise/http-message/v/stable?format=flat)](https://packagist.org/packages/sunrise/http-message)
[![License](https://poser.pugx.org/sunrise/http-message/license?format=flat)](https://packagist.org/packages/sunrise/http-message)

[![SymfonyInsight](https://insight.symfony.com/projects/62934e27-3e71-439c-9569-4aa57cdb3f36/big.svg)](https://insight.symfony.com/projects/62934e27-3e71-439c-9569-4aa57cdb3f36)
---

## Installation

```bash
composer require sunrise/http-message
composer require 'sunrise/http-message:^2.0'
```

## How to use?
Expand All @@ -40,35 +37,7 @@ $message = (new ResponseFactory)->createResponse(200, 'OK');
// just use PSR-7 methods...
```


#### Using headers as objects

> Please note that this isn't related to the PSR-7...
```bash
composer require sunrise/http-header-kit
```

```php
use Sunrise\Http\Header\HeaderLastModified;

$header = new HeaderLastModified(new \DateTime('1 day ago'));

$response = $response->withHeaderObject($header);
```

```php
use Sunrise\Http\Header\HeaderCollection;
use Sunrise\Http\Header\HeaderContentLength;
use Sunrise\Http\Header\HeaderContentType;

$headers = new HeaderCollection([
new HeaderContentLength(1024),
new HeaderContentType('application/jpeg'),
]);

$response = $response->withHeaderCollection($headers);
```
#### HTTP Headers as Objects

* https://github.com/sunrise-php/http-header-kit

Expand All @@ -78,10 +47,12 @@ $response = $response->withHeaderCollection($headers);
* https://github.com/sunrise-php/stream
* https://github.com/sunrise-php/uri

---

## Test run

```bash
php vendor/bin/phpunit
composer test
```

## Useful links
Expand Down
22 changes: 15 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{
"name": "sunrise/http-message",
"homepage": "https://github.com/sunrise-php/http-message",
"description": "Sunrise HTTP message wrapper for PHP 7.1+ based on RFC-7230, PSR-7 & PSR-17",
"description": "Sunrise // HTTP message wrapper for PHP 7.1+ based on RFC-7230, PSR-7 and PSR-17",
"license": "MIT",
"keywords": [
"fenric",
"sunrise",
"http",
"http-message",
"http-request",
"http-response",
"rfc-7230",
"psr-7",
"psr-17"
"psr-17",
"php-7",
"php-8"
],
"authors": [
{
Expand All @@ -21,10 +25,10 @@
],
"require": {
"php": "^7.1|^8.0",
"fig/http-message-util": "^1.1",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"sunrise/http-header": "^1.1",
"sunrise/http-header-collection": "^1.1",
"sunrise/http-header": "^2.0",
"sunrise/stream": "^1.2",
"sunrise/uri": "^1.2"
},
Expand All @@ -37,16 +41,20 @@
},
"autoload": {
"files": [
"data/phrases.php"
"constants/REASON_PHRASES.php"
],
"psr-4": {
"Sunrise\\Http\\Message\\": "src/"
}
},
"scripts": {
"test": [
"phpunit --colors=always --coverage-text",
"phpcs"
"phpcs",
"XDEBUG_MODE=coverage phpunit --coverage-text --colors=always"
],
"build": [
"phpdoc -d src/ -t phpdoc/",
"XDEBUG_MODE=coverage phpunit --coverage-html coverage/"
]
}
}
8 changes: 2 additions & 6 deletions data/phrases.php → constants/REASON_PHRASES.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
namespace Sunrise\Http\Message;

/**
* List of Phrases
*
* MUST NOT be used outside of this package.
* List of Reason Phrases
*
* @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
*/
const PHRASES = [
const REASON_PHRASES = [

// 1xx
100 => 'Continue',
Expand All @@ -45,7 +43,6 @@
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
306 => '(Unused)',
307 => 'Temporary Redirect',
308 => 'Permanent Redirect',

Expand All @@ -68,7 +65,6 @@
415 => 'Unsupported Media Type',
416 => 'Range Not Satisfiable',
417 => 'Expectation Failed',
418 => 'I\'m a teapot',
421 => 'Misdirected Request',
422 => 'Unprocessable Entity',
423 => 'Locked',
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ruleset name="Sunrise Coding Standard">
<rule ref="./vendor/sunrise/coding-standard/ruleset.xml"/>

<file>data</file>
<file>constants</file>
<file>src</file>
<file>tests</file>
</ruleset>
20 changes: 7 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
<?xml version="1.0"?>
<phpunit colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Sunrise HTTP Message Test Suite">
<testsuite name="sunrise.http.message.testSuite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
<php>
<const name="REQUEST_FACTORY" value="Sunrise\Http\Message\RequestFactory"/>
<const name="RESPONSE_FACTORY" value="Sunrise\Http\Message\ResponseFactory"/>
<const name="STREAM_FACTORY" value="Sunrise\Stream\StreamFactory"/>
<const name="URI_FACTORY" value="Sunrise\Uri\UriFactory"/>
</php>
</phpunit>
51 changes: 0 additions & 51 deletions src/Exception/JsonException.php

This file was deleted.

Loading

0 comments on commit 5f8159f

Please sign in to comment.