Skip to content

Commit f9da86c

Browse files
committed
1 parent 2d14511 commit f9da86c

26 files changed

+4318
-67
lines changed

.github/workflows/ci.yml

+1-26
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ on:
2121
name: "Continuous Integration"
2222

2323
env:
24-
PHP_EXTENSIONS: "" # caution: setting 'none' resets/disables shared extensions
24+
PHP_EXTENSIONS: fileinfo, intl, json, mbstring, simplexml, sodium, zlib
2525
PHP_INI_VALUES: memory_limit=-1, error_reporting=-1, display_errors=On
2626

2727
jobs:
@@ -137,28 +137,3 @@ jobs:
137137
branch: gh-pages
138138
folder: .build/phpdocs
139139
clean: true
140-
141-
142-
build-manual:
143-
name: "Build and publish user manual"
144-
if: github.ref_name == 'main'
145-
runs-on: ubuntu-latest
146-
147-
steps:
148-
- name: "Checkout sources"
149-
uses: actions/checkout@v4
150-
151-
- name: "Install Sphinx"
152-
run: pip install sphinx myst-parser sphinx-rtd-theme
153-
154-
- name: "Build manual"
155-
run: |
156-
cd docs
157-
make html
158-
159-
- name: "Publish user manual to branch readthedocs"
160-
uses: JamesIves/github-pages-deploy-action@v4
161-
with:
162-
branch: readthedocs
163-
folder: .build/sphinx/html
164-
clean: true

.phan/config.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
// Thus, both first-party and third-party code being used by
2828
// your application should be included in this list.
2929
'directory_list' => [
30-
'.phan/stubs',
31-
'examples',
30+
# '.phan/stubs',
31+
# 'examples',
3232
'src',
3333
'tests',
3434
'vendor',
@@ -57,5 +57,7 @@
5757
],
5858
'suppress_issue_types' => [
5959
'PhanAccessMethodInternal',
60+
'PhanNoopCast',
61+
'PhanNoopNew',
6062
],
6163
];

README.md

+43-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# chillerlan/php-library-template
1+
# chillerlan/psr-7
22

3-
A template/boilerplate for PHP libraries.
3+
A [PSR-7](https://www.php-fig.org/psr/psr-7/)/[PSR-17](https://www.php-fig.org/psr/psr-17/) HTTP message and factory implementation.
44

55
[![PHP Version Support][php-badge]][php]
66
[![Packagist version][packagist-badge]][packagist]
@@ -10,46 +10,62 @@ A template/boilerplate for PHP libraries.
1010
[![Codacy][codacy-badge]][codacy]
1111
[![Packagist downloads][downloads-badge]][downloads]
1212

13-
[php-badge]: https://img.shields.io/packagist/php-v/chillerlan/php-library-template?logo=php&color=8892BF&logoColor=fff
13+
[php-badge]: https://img.shields.io/packagist/php-v/chillerlan/psr-7?logo=php&color=8892BF&logoColor=fff
1414
[php]: https://www.php.net/supported-versions.php
15-
[packagist-badge]: https://img.shields.io/packagist/v/chillerlan/php-library-template.svg?logo=packagist&logoColor=fff
16-
[packagist]: https://packagist.org/packages/chillerlan/php-library-template
17-
[license-badge]: https://img.shields.io/github/license/chillerlan/php-library-template.svg
18-
[license]: https://github.com/chillerlan/php-library-template/blob/main/LICENSE
19-
[gh-action-badge]: https://img.shields.io/github/actions/workflow/status/chillerlan/php-library-template/ci.yml?branch=main&logo=github&logoColor=fff
20-
[gh-action]: https://github.com/chillerlan/php-library-template/actions/workflows/ci.yml?query=branch%3Amain
21-
[coverage-badge]: https://img.shields.io/codecov/c/github/chillerlan/php-library-template.svg?logo=codecov&logoColor=fff
22-
[coverage]: https://codecov.io/github/chillerlan/php-library-template
15+
[packagist-badge]: https://img.shields.io/packagist/v/chillerlan/psr-7.svg?logo=packagist&logoColor=fff
16+
[packagist]: https://packagist.org/packages/chillerlan/psr-7
17+
[license-badge]: https://img.shields.io/github/license/chillerlan/psr-7.svg
18+
[license]: https://github.com/chillerlan/psr-7/blob/main/LICENSE
19+
[gh-action-badge]: https://img.shields.io/github/actions/workflow/status/chillerlan/psr-7/ci.yml?branch=main&logo=github&logoColor=fff
20+
[gh-action]: https://github.com/chillerlan/psr-7/actions/workflows/ci.yml?query=branch%3Amain
21+
[coverage-badge]: https://img.shields.io/codecov/c/github/chillerlan/psr-7.svg?logo=codecov&logoColor=fff
22+
[coverage]: https://codecov.io/github/chillerlan/psr-7
2323
[codacy-badge]: https://img.shields.io/codacy/grade/de971588f9a44f1a99e7bbd2a0737951?logo=codacy&logoColor=fff
24-
[codacy]: https://app.codacy.com/gh/chillerlan/php-library-template/dashboard
25-
[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/php-library-template.svg?logo=packagist&logoColor=fff
26-
[downloads]: https://packagist.org/packages/chillerlan/php-library-template/stats
24+
[codacy]: https://app.codacy.com/gh/chillerlan/psr-7/dashboard
25+
[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/psr-7.svg?logo=packagist&logoColor=fff
26+
[downloads]: https://packagist.org/packages/chillerlan/psr-7/stats
2727

2828
## Overview
2929

3030
### Features
3131

32-
- [GitHub Actions](https://github.com/chillerlan/php-library-template/actions) runner
33-
- [Composer](https://getcomposer.org) dependency management
34-
- [PHPUnit](https://phpunit.de) unit tests
35-
- [PHAN](https://github.com/phan/phan) static analysis
36-
- [PHPCS](https://github.com/PHPCSStandards/PHP_CodeSniffer) coding standard analyzer
37-
- [PHPMD](https://phpmd.org) mess detector
38-
- [Codecov](https://codecov.io) code coverage analysis
39-
- [Codacy](https://www.codacy.com) code quality analysis
40-
- [phpDocumentor](https://www.phpdoc.org) auto generated API docs
41-
- [ReadTheDocs](https://readthedocs.org) documentation builder
42-
32+
- [PSR-7](https://www.php-fig.org/psr/psr-7/) HTTP message implementation
33+
- [PSR-17](https://www.php-fig.org/psr/psr-17/) HTTP factory implementation
34+
- `MultipartStreamBuilder` based on PSR-7 `Message` objects ([RFC-2046, section 5.1](https://datatracker.ietf.org/doc/html/rfc2046#section-5.1))
4335

4436
### Requirements
4537

4638
- PHP 8.1+
39+
- [`ext-mbstring`](https://www.php.net/manual/book.mbstring.php)
4740

4841

4942
## Documentation
5043

51-
- The user manual is at https://php-library-template.readthedocs.io/ ([sources](https://github.com/chillerlan/php-library-template/tree/main/docs))
52-
- An API documentation created with [phpDocumentor](https://www.phpdoc.org/) can be found at https://chillerlan.github.io/php-library-template/
44+
The documentation of the PSR-7 interfaces can be found over at https://www.php-fig.org/psr/psr-7/.
45+
46+
**NOTE: This library has abandoned the paranoid "value object" "immuatbility" that is dictated by PSR-7 for it is horseshit.
47+
The pseudo-immutability gets in the way more often (always) than it is useful (never) and creates endless overhead.
48+
If you want your objects to be immutable for whatever reason, just fucking clone them and don't force countless libraries
49+
to do that for you instead. If you don't like it, just use Guzzle instead (spoiler: you won't notice the difference).**
50+
51+
Further, this library still only implements [`psr/http-message`](https://packagist.org/packages/psr/http-message) v1.1,
52+
as the v2.0 release (06/2023) has return types added [that conflict](https://github.com/php-fig/http-message/pull/107)
53+
with the [`static` return type](https://wiki.php.net/rfc/static_return_type) that was introduced in PHP 8 (11/2020).
54+
55+
56+
### Auto generated API documentation
57+
58+
The API documentation can be auto generated with [phpDocumentor](https://www.phpdoc.org/).
59+
There is an [online version available](https://chillerlan.github.io/psr-7/) via the [gh-pages branch](https://github.com/chillerlan/psr-7/tree/gh-pages) that is [automatically deployed](https://github.com/chillerlan/psr-7/deployments) on each push to main.
60+
61+
Locally created docs will appear in `.build/phpdocs/`. If you'd like to create local docs, please follow these steps:
62+
63+
- [download phpDocumentor](https://github.com/phpDocumentor/phpDocumentor/releases) v3+ as .phar archive
64+
- run it in the repository root directory:
65+
- on Windows `c:\path\to\php.exe c:\path\to\phpDocumentor.phar --config=phpdoc.xml`
66+
- on Linux just `php /path/to/phpDocumentor.phar --config=phpdoc.xml`
67+
- open [index.html](./.build/phpdocs/index.html) in a browser
68+
- profit!
5369

5470

5571
## Disclaimer

composer.json

+26-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
2-
"name": "chillerlan/php-library-template",
3-
"description": "A PHP Library template/boilerplate.",
2+
"name": "chillerlan/psr-7",
3+
"description": "A PSR-7 HTTP message and PSR-17 HTTP factory implementation.",
44
"license": "MIT",
55
"type": "library",
6-
"keywords": ["boilerplate", "library-template"],
6+
"keywords": [
7+
"http", "message", "factory", "psr-7", "psr-17", "request", "response", "message", "stream", "uri", "url"
8+
],
79
"authors": [
810
{
911
"name": "smiley",
@@ -12,36 +14,49 @@
1214
},
1315
{
1416
"name": "Contributors",
15-
"homepage":"https://github.com/chillerlan/php-library-template/graphs/contributors"
17+
"homepage":"https://github.com/chillerlan/psr-7/graphs/contributors"
1618
}
1719
],
18-
"homepage": "https://github.com/chillerlan/php-library-template",
20+
"homepage": "https://github.com/chillerlan/psr-7",
1921
"support": {
20-
"docs": "https://php-library-template.readthedocs.io",
21-
"issues": "https://github.com/chillerlan/php-library-template/issues",
22-
"source": "https://github.com/chillerlan/php-library-template"
22+
"docs": "https://chillerlan.github.io/psr-7/",
23+
"issues": "https://github.com/chillerlan/psr-7/issues",
24+
"source": "https://github.com/chillerlan/psr-7"
25+
},
26+
"provide": {
27+
"psr/http-factory-implementation": "1.0",
28+
"psr/http-message-implementation": "1.0"
2329
},
2430
"minimum-stability": "stable",
2531
"prefer-stable": true,
2632
"require": {
27-
"php": "^8.1"
33+
"php": "^8.1",
34+
"ext-mbstring": "*",
35+
"chillerlan/php-http-message-utils": "^2.1.1",
36+
"fig/http-message-util": "^1.1.5",
37+
"psr/http-message": "^1.1",
38+
"psr/http-factory": "^1.0"
2839
},
2940
"require-dev": {
41+
"ext-simplexml": "*",
42+
"http-interop/http-factory-tests": "^2.1",
3043
"phan/phan": "^5.4",
3144
"phpunit/phpunit": "^10.5",
3245
"phpmd/phpmd": "^2.15",
3346
"squizlabs/php_codesniffer": "^3.9"
3447
},
3548
"suggest": {
49+
"chillerlan/php-httpinterface": "A PSR-18 HTTP client implementation",
50+
"chillerlan/php-oauth": "A PSR-7 OAuth client/handler that also acts as PSR-18 HTTP client"
3651
},
3752
"autoload": {
3853
"psr-4": {
39-
"chillerlan\\LibraryTemplate\\": "src/"
54+
"chillerlan\\HTTP\\Psr7\\": "src/"
4055
}
4156
},
4257
"autoload-dev": {
4358
"psr-4": {
44-
"chillerlan\\LibraryTemplateTest\\": "tests/"
59+
"chillerlan\\HTTPTest\\Psr7\\": "tests/"
4560
}
4661
},
4762
"scripts": {

phpunit.xml.dist

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
colors="true"
77
>
88
<testsuites>
9-
<testsuite name="chillerlan test suite">
9+
<testsuite name="chillerlan/psr-7 test suite">
1010
<directory>./tests/</directory>
1111
</testsuite>
12+
<testsuite name="http-interop integration tests">
13+
<directory>./vendor/http-interop/http-factory-tests/test</directory>
14+
</testsuite>
1215
</testsuites>
1316
<source>
1417
<include>
@@ -21,4 +24,12 @@
2124
<xml outputDirectory=".build/coverage/coverage-xml"/>
2225
</report>
2326
</coverage>
27+
<php>
28+
<const name="REQUEST_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
29+
<const name="RESPONSE_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
30+
<const name="SERVER_REQUEST_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
31+
<const name="STREAM_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
32+
<const name="UPLOADED_FILE_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
33+
<const name="URI_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
34+
</php>
2435
</phpunit>

0 commit comments

Comments
 (0)