Skip to content

Commit

Permalink
Merge branch 'release/5.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Zegnat committed Oct 24, 2018
2 parents 3519d0f + 7bbe1b4 commit 760a56a
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 104 deletions.
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,46 @@ $ composer create-project zegnat/website-starter

1. Using [Auryn][] to get actual dependency injections. Never pass around
a container.
2. Using [Diactoros][] to only have to work with
[PSR-7 Requests and Responses][PSR-7].
3. Using [Middleland][] to run through all configured
2. Using [PSR-7 HTTP message objects][PSR-7] with [PSR-17 factories][PSR-17]
for all request and response handling.
3. Using [nyholm/psr7-server][] to create the initial [PSR-7][] request.
4. Using [Middleland][] to run through all configured
[PSR-15 Middlewares][PSR-15].
4. Using [FastRoute][] to parse requested URIs and find the matching
5. Using [FastRoute][] to parse requested URIs and find the matching
[PSR-15 RequestHandlers][PSR-15].
5. Using [PHP_CodeSniffer][] to check all code against the
6. Using [PHP_CodeSniffer][] to check all code against the
[PSR-2 Coding Style Guide][PSR-2].
7. Using a [Zend Emitter][] to output a final response to the web server.

## PSR-7 & PSR-17 Providers

By default this project loads [Diactoros][] for its [PSR-7][] objects and
matching [PSR-17][] factories.

The providers can easily be swapped for a different set of implementations.
Simply remove the dependency from composer and add a new one. Example:

```bash
$ composer remove zendframework/zend-diactoros
$ composer require nyholm/psr7
```

Then change [the injector configuration](config/injector.php) to tell
[Auryn][] which factories it should use. In the case of [nyholm/psr7][] all of
them can be defined as `Nyholm\Psr7\Factory\Psr17Factory::class`.

[Auryn]: https://github.com/rdlowrey/auryn
[Diactoros]: https://zendframework.github.io/zend-diactoros/
[FastRoute]: https://github.com/nikic/FastRoute
[Middleland]: https://github.com/oscarotero/middleland
[nyholm/psr7]: https://github.com/Nyholm/psr7
[nyholm/psr7-server]: https://github.com/Nyholm/psr7-server
[PHP_CodeSniffer]: https://github.com/squizlabs/PHP_CodeSniffer
[PSR-2]: http://www.php-fig.org/psr/psr-2/
[PSR-7]: http://www.php-fig.org/psr/psr-7/
[PSR-15]: https://www.php-fig.org/psr/psr-15/
[PSR-17]: https://www.php-fig.org/psr/psr-17/
[Zend Emitter]: https://docs.zendframework.com/zend-httphandlerrunner/emitters/

## License

Expand Down
10 changes: 9 additions & 1 deletion app/RequestHandler/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@

use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ServerRequestInterface;

class Home implements RequestHandlerInterface
{
private $response;

public function __construct(ResponseFactoryInterface $responseFactory)
{
$this->responseFactory = $responseFactory;
}

public function handle(ServerRequestInterface $request): ResponseInterface
{
return new \Zend\Diactoros\Response\EmptyResponse;
return $this->responseFactory->createResponse();
}
}
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "zegnat/website-starter",
"description": "My minimum viable setup for starting a PHP project.",
"type": "project",
"version": "4.0.0",
"version": "5.0.0",
"license": "0BSD",
"authors": [
{
Expand All @@ -14,13 +14,15 @@
"psr-4": {"app\\": "app/"}
},
"require": {
"middlewares/fast-route": "^1.0",
"middlewares/fast-route": "^1.2",
"nyholm/psr7-server": "^0.3.0",
"oscarotero/middleland": "^1.0",
"rdlowrey/auryn": "^1.4",
"zendframework/zend-diactoros": "^1.7"
"zendframework/zend-diactoros": "^2.0",
"zendframework/zend-httphandlerrunner": "^1.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.2"
"squizlabs/php_codesniffer": "^3.3"
},
"scripts": {
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 app config public"
Expand Down
Loading

0 comments on commit 760a56a

Please sign in to comment.