Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Mar 9, 2024
1 parent 2d14511 commit f9da86c
Show file tree
Hide file tree
Showing 26 changed files with 4,318 additions and 67 deletions.
27 changes: 1 addition & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
name: "Continuous Integration"

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

jobs:
Expand Down Expand Up @@ -137,28 +137,3 @@ jobs:
branch: gh-pages
folder: .build/phpdocs
clean: true


build-manual:
name: "Build and publish user manual"
if: github.ref_name == 'main'
runs-on: ubuntu-latest

steps:
- name: "Checkout sources"
uses: actions/checkout@v4

- name: "Install Sphinx"
run: pip install sphinx myst-parser sphinx-rtd-theme

- name: "Build manual"
run: |
cd docs
make html
- name: "Publish user manual to branch readthedocs"
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: readthedocs
folder: .build/sphinx/html
clean: true
6 changes: 4 additions & 2 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
// Thus, both first-party and third-party code being used by
// your application should be included in this list.
'directory_list' => [
'.phan/stubs',
'examples',
# '.phan/stubs',
# 'examples',
'src',
'tests',
'vendor',
Expand Down Expand Up @@ -57,5 +57,7 @@
],
'suppress_issue_types' => [
'PhanAccessMethodInternal',
'PhanNoopCast',
'PhanNoopNew',
],
];
70 changes: 43 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# chillerlan/php-library-template
# chillerlan/psr-7

A template/boilerplate for PHP libraries.
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.

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

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

## Overview

### Features

- [GitHub Actions](https://github.com/chillerlan/php-library-template/actions) runner
- [Composer](https://getcomposer.org) dependency management
- [PHPUnit](https://phpunit.de) unit tests
- [PHAN](https://github.com/phan/phan) static analysis
- [PHPCS](https://github.com/PHPCSStandards/PHP_CodeSniffer) coding standard analyzer
- [PHPMD](https://phpmd.org) mess detector
- [Codecov](https://codecov.io) code coverage analysis
- [Codacy](https://www.codacy.com) code quality analysis
- [phpDocumentor](https://www.phpdoc.org) auto generated API docs
- [ReadTheDocs](https://readthedocs.org) documentation builder

- [PSR-7](https://www.php-fig.org/psr/psr-7/) HTTP message implementation
- [PSR-17](https://www.php-fig.org/psr/psr-17/) HTTP factory implementation
- `MultipartStreamBuilder` based on PSR-7 `Message` objects ([RFC-2046, section 5.1](https://datatracker.ietf.org/doc/html/rfc2046#section-5.1))

### Requirements

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


## Documentation

- The user manual is at https://php-library-template.readthedocs.io/ ([sources](https://github.com/chillerlan/php-library-template/tree/main/docs))
- An API documentation created with [phpDocumentor](https://www.phpdoc.org/) can be found at https://chillerlan.github.io/php-library-template/
The documentation of the PSR-7 interfaces can be found over at https://www.php-fig.org/psr/psr-7/.

**NOTE: This library has abandoned the paranoid "value object" "immuatbility" that is dictated by PSR-7 for it is horseshit.
The pseudo-immutability gets in the way more often (always) than it is useful (never) and creates endless overhead.
If you want your objects to be immutable for whatever reason, just fucking clone them and don't force countless libraries
to do that for you instead. If you don't like it, just use Guzzle instead (spoiler: you won't notice the difference).**

Further, this library still only implements [`psr/http-message`](https://packagist.org/packages/psr/http-message) v1.1,
as the v2.0 release (06/2023) has return types added [that conflict](https://github.com/php-fig/http-message/pull/107)
with the [`static` return type](https://wiki.php.net/rfc/static_return_type) that was introduced in PHP 8 (11/2020).


### Auto generated API documentation

The API documentation can be auto generated with [phpDocumentor](https://www.phpdoc.org/).
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.

Locally created docs will appear in `.build/phpdocs/`. If you'd like to create local docs, please follow these steps:

- [download phpDocumentor](https://github.com/phpDocumentor/phpDocumentor/releases) v3+ as .phar archive
- run it in the repository root directory:
- on Windows `c:\path\to\php.exe c:\path\to\phpDocumentor.phar --config=phpdoc.xml`
- on Linux just `php /path/to/phpDocumentor.phar --config=phpdoc.xml`
- open [index.html](./.build/phpdocs/index.html) in a browser
- profit!


## Disclaimer
Expand Down
37 changes: 26 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "chillerlan/php-library-template",
"description": "A PHP Library template/boilerplate.",
"name": "chillerlan/psr-7",
"description": "A PSR-7 HTTP message and PSR-17 HTTP factory implementation.",
"license": "MIT",
"type": "library",
"keywords": ["boilerplate", "library-template"],
"keywords": [
"http", "message", "factory", "psr-7", "psr-17", "request", "response", "message", "stream", "uri", "url"
],
"authors": [
{
"name": "smiley",
Expand All @@ -12,36 +14,49 @@
},
{
"name": "Contributors",
"homepage":"https://github.com/chillerlan/php-library-template/graphs/contributors"
"homepage":"https://github.com/chillerlan/psr-7/graphs/contributors"
}
],
"homepage": "https://github.com/chillerlan/php-library-template",
"homepage": "https://github.com/chillerlan/psr-7",
"support": {
"docs": "https://php-library-template.readthedocs.io",
"issues": "https://github.com/chillerlan/php-library-template/issues",
"source": "https://github.com/chillerlan/php-library-template"
"docs": "https://chillerlan.github.io/psr-7/",
"issues": "https://github.com/chillerlan/psr-7/issues",
"source": "https://github.com/chillerlan/psr-7"
},
"provide": {
"psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0"
},
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": "^8.1"
"php": "^8.1",
"ext-mbstring": "*",
"chillerlan/php-http-message-utils": "^2.1.1",
"fig/http-message-util": "^1.1.5",
"psr/http-message": "^1.1",
"psr/http-factory": "^1.0"
},
"require-dev": {
"ext-simplexml": "*",
"http-interop/http-factory-tests": "^2.1",
"phan/phan": "^5.4",
"phpunit/phpunit": "^10.5",
"phpmd/phpmd": "^2.15",
"squizlabs/php_codesniffer": "^3.9"
},
"suggest": {
"chillerlan/php-httpinterface": "A PSR-18 HTTP client implementation",
"chillerlan/php-oauth": "A PSR-7 OAuth client/handler that also acts as PSR-18 HTTP client"
},
"autoload": {
"psr-4": {
"chillerlan\\LibraryTemplate\\": "src/"
"chillerlan\\HTTP\\Psr7\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"chillerlan\\LibraryTemplateTest\\": "tests/"
"chillerlan\\HTTPTest\\Psr7\\": "tests/"
}
},
"scripts": {
Expand Down
13 changes: 12 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
colors="true"
>
<testsuites>
<testsuite name="chillerlan test suite">
<testsuite name="chillerlan/psr-7 test suite">
<directory>./tests/</directory>
</testsuite>
<testsuite name="http-interop integration tests">
<directory>./vendor/http-interop/http-factory-tests/test</directory>
</testsuite>
</testsuites>
<source>
<include>
Expand All @@ -21,4 +24,12 @@
<xml outputDirectory=".build/coverage/coverage-xml"/>
</report>
</coverage>
<php>
<const name="REQUEST_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
<const name="RESPONSE_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
<const name="SERVER_REQUEST_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
<const name="STREAM_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
<const name="UPLOADED_FILE_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
<const name="URI_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
</php>
</phpunit>
Loading

0 comments on commit f9da86c

Please sign in to comment.