Skip to content

Commit

Permalink
Last few changes for the first release
Browse files Browse the repository at this point in the history
  • Loading branch information
victorwelling committed Dec 12, 2017
1 parent 9d0fa43 commit f1c3fb9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Changelog
All notable changes to Shoot will be documented in this file.

## [0.1.0] - 2017-12-12
### Added
- First release!
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,18 @@ $ composer require shoot/shoot
```

## Usage
Below you'll find a request handler serving blog posts. Note the context being set for the pipeline. The pipeline is
part of Shoot, and all views being rendered pass through it. This context is available to all middleware and presenters.
You'll see how it's used further down.
First, set up Shoot's pipeline. All views being rendered pass through it, and are processed by its middleware. For Shoot
to be useful, you'll need at least the PresenterMiddleware, which takes a PSR-11 compliant DI container as its
dependency. All that's left is then to add it to Twig as an extension:

```php
$pipeline = new Pipeline([new PresenterMiddleware($container)]);

$twig->addExtension($pipeline);
```

Below you'll find a request handler serving blog posts. Note the context being set for the pipeline. This context is
available to all middleware and presenters. You'll see how it's used further down.

```php
$app->get('/posts/{post_id}', function ($request, $response) {
Expand Down Expand Up @@ -99,8 +108,8 @@ final class Post extends PresentationModel implements HasPresenter
}
```

The presentation model in turn has the following presenter. Note that presenters are loaded from any PSR-11 compliant DI
container, so each presenter can have its own dependencies.
The presentation model in turn has the following presenter. Since presenters are loaded from a DI container, each
presenter can have its own dependencies to load and format data.

```php
final class PostPresenter implements PresenterInterface
Expand Down Expand Up @@ -164,4 +173,4 @@ The MIT License (MIT). Please see the [license file][link-license] for more info
[link-coverage]: https://scrutinizer-ci.com/g/shootphp/shoot/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/shootphp/shoot
[link-empty-values]: https://secure.php.net/empty
[link-license]: LICENSE.md
[link-license]: LICENSE.md

0 comments on commit f1c3fb9

Please sign in to comment.