Skip to content

Commit c9831fe

Browse files
committed
Doc updates
1 parent 800cb4a commit c9831fe

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ Most of features are directly inherited from [PHP React HTTP](https://github.com
1919
* Basic routing
2020
* Basic [PSR-3 logging](https://www.php-fig.org/psr/psr-3/)
2121
* Static files serving
22-
* Focus on **returning** data, not **building response to render** data
23-
* Route handlers can return simple array or objects
22+
* Let you focus on **your service logic**, not **building a HTTP response** (boooring)
23+
* Just return `arrays` or `objects` in your route handlers, that's it:
24+
```php
25+
function (ServerRequestInterface $request) {
26+
return ['hello' => 'world'];
27+
}
28+
```
2429

2530
## Install
2631
Install with [composer](https://getcomposer.org/):
@@ -29,8 +34,13 @@ composer require phpbg/mini-httpd
2934
```
3035

3136
## Examples
32-
See `example` folder for a complete demo.
37+
See `example` folder
38+
* `bare-minimal-json-server.php` shows the very minimal setup for json rendering
39+
* `full-featured-server.php` shows a full setup with:
40+
* Static files serving
41+
* Route redirection examples
42+
* Automatic PHTML renderer features and suggested layout
43+
* Accessing request params with proper validation / filtering
3344

3445
## TODO
35-
* writing tests
36-
* writing at least one HTML renderer
46+
* writing tests

example/full-featured-server.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
// Controller callback, with request manipulation, that return a promise
2929
'/api/task/add-async' => new \PhpBg\MiniHttpd\Model\Route([$taskController, 'addAsync'], $jsonRenderer),
3030

31+
// This is the suggested example for all your PHTML pages
32+
// It consists of
33+
// * Demo.php: a PHP controller that will handle the request
34+
// * Demo.phtml: a file that will receive controller data and generate a response
35+
// * optional Demo.css and Demo.js files that will be inlined with the response
3136
'/demo' => new \PhpBg\MiniHttpd\Model\Route(new Demo(), new \PhpBg\MiniHttpd\Renderer\Phtml\Phtml(__DIR__ . '/pages/layout.phtml')),
3237
];
3338

0 commit comments

Comments
 (0)