Skip to content

Commit 760a56a

Browse files
committed
Merge branch 'release/5.0.0'
2 parents 3519d0f + 7bbe1b4 commit 760a56a

File tree

6 files changed

+284
-104
lines changed

6 files changed

+284
-104
lines changed

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,46 @@ $ composer create-project zegnat/website-starter
2525

2626
1. Using [Auryn][] to get actual dependency injections. Never pass around
2727
a container.
28-
2. Using [Diactoros][] to only have to work with
29-
[PSR-7 Requests and Responses][PSR-7].
30-
3. Using [Middleland][] to run through all configured
28+
2. Using [PSR-7 HTTP message objects][PSR-7] with [PSR-17 factories][PSR-17]
29+
for all request and response handling.
30+
3. Using [nyholm/psr7-server][] to create the initial [PSR-7][] request.
31+
4. Using [Middleland][] to run through all configured
3132
[PSR-15 Middlewares][PSR-15].
32-
4. Using [FastRoute][] to parse requested URIs and find the matching
33+
5. Using [FastRoute][] to parse requested URIs and find the matching
3334
[PSR-15 RequestHandlers][PSR-15].
34-
5. Using [PHP_CodeSniffer][] to check all code against the
35+
6. Using [PHP_CodeSniffer][] to check all code against the
3536
[PSR-2 Coding Style Guide][PSR-2].
37+
7. Using a [Zend Emitter][] to output a final response to the web server.
38+
39+
## PSR-7 & PSR-17 Providers
40+
41+
By default this project loads [Diactoros][] for its [PSR-7][] objects and
42+
matching [PSR-17][] factories.
43+
44+
The providers can easily be swapped for a different set of implementations.
45+
Simply remove the dependency from composer and add a new one. Example:
46+
47+
```bash
48+
$ composer remove zendframework/zend-diactoros
49+
$ composer require nyholm/psr7
50+
```
51+
52+
Then change [the injector configuration](config/injector.php) to tell
53+
[Auryn][] which factories it should use. In the case of [nyholm/psr7][] all of
54+
them can be defined as `Nyholm\Psr7\Factory\Psr17Factory::class`.
3655

3756
[Auryn]: https://github.com/rdlowrey/auryn
3857
[Diactoros]: https://zendframework.github.io/zend-diactoros/
3958
[FastRoute]: https://github.com/nikic/FastRoute
4059
[Middleland]: https://github.com/oscarotero/middleland
60+
[nyholm/psr7]: https://github.com/Nyholm/psr7
61+
[nyholm/psr7-server]: https://github.com/Nyholm/psr7-server
4162
[PHP_CodeSniffer]: https://github.com/squizlabs/PHP_CodeSniffer
4263
[PSR-2]: http://www.php-fig.org/psr/psr-2/
4364
[PSR-7]: http://www.php-fig.org/psr/psr-7/
4465
[PSR-15]: https://www.php-fig.org/psr/psr-15/
66+
[PSR-17]: https://www.php-fig.org/psr/psr-17/
67+
[Zend Emitter]: https://docs.zendframework.com/zend-httphandlerrunner/emitters/
4568

4669
## License
4770

app/RequestHandler/Home.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66

77
use Psr\Http\Server\RequestHandlerInterface;
88
use Psr\Http\Message\ResponseInterface;
9+
use Psr\Http\Message\ResponseFactoryInterface;
910
use Psr\Http\Message\ServerRequestInterface;
1011

1112
class Home implements RequestHandlerInterface
1213
{
14+
private $response;
15+
16+
public function __construct(ResponseFactoryInterface $responseFactory)
17+
{
18+
$this->responseFactory = $responseFactory;
19+
}
20+
1321
public function handle(ServerRequestInterface $request): ResponseInterface
1422
{
15-
return new \Zend\Diactoros\Response\EmptyResponse;
23+
return $this->responseFactory->createResponse();
1624
}
1725
}

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "zegnat/website-starter",
33
"description": "My minimum viable setup for starting a PHP project.",
44
"type": "project",
5-
"version": "4.0.0",
5+
"version": "5.0.0",
66
"license": "0BSD",
77
"authors": [
88
{
@@ -14,13 +14,15 @@
1414
"psr-4": {"app\\": "app/"}
1515
},
1616
"require": {
17-
"middlewares/fast-route": "^1.0",
17+
"middlewares/fast-route": "^1.2",
18+
"nyholm/psr7-server": "^0.3.0",
1819
"oscarotero/middleland": "^1.0",
1920
"rdlowrey/auryn": "^1.4",
20-
"zendframework/zend-diactoros": "^1.7"
21+
"zendframework/zend-diactoros": "^2.0",
22+
"zendframework/zend-httphandlerrunner": "^1.0"
2123
},
2224
"require-dev": {
23-
"squizlabs/php_codesniffer": "^3.2"
25+
"squizlabs/php_codesniffer": "^3.3"
2426
},
2527
"scripts": {
2628
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 app config public"

0 commit comments

Comments
 (0)