Skip to content

Commit

Permalink
Merge pull request #2841 from mokevnin/patch-1
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
l0gicgate authored Sep 21, 2019
2 parents 4d490ab + 9a1c775 commit 62b7295
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ In order for auto-detection to work and enable you to use `AppFactory::create()`
- [Guzzle/psr7](https://github.com/guzzle/psr7) & [http-interop/http-factory-guzzle](https://github.com/http-interop/http-factory-guzzle) - Install using `composer require guzzlehttp/psr7 http-interop/http-factory-guzzle`
- [zend-diactoros](https://github.com/zendframework/zend-diactoros) - Install using `composer require zendframework/zend-diactoros`

Then create file _public/index.php_.

```php
<?php
use Psr\Http\Message\ResponseInterface as Response;
Expand All @@ -71,7 +73,12 @@ $app = AppFactory::create();
// Add error middleware
$app->addErrorMiddleware(true, true, true);

// Add route
// Add routes
$app->get('/', function () {
$response->getBody()->write('<a href="/hello/world">Try /hello/world</a>');
return $response;
});

$app->get('/hello/{name}', function (Request $request, Response $response, $args) {
$name = $args['name'];
$response->getBody()->write("Hello, $name");
Expand All @@ -83,7 +90,7 @@ $app->run();

You may quickly test this using the built-in PHP server:
```bash
$ php -S localhost:8000
$ php -S localhost:8000 -t public
```

Going to http://localhost:8000/hello/world will now display "Hello, world".
Expand Down

0 comments on commit 62b7295

Please sign in to comment.