diff options
author | Arnold Daniels <arnold@jasny.net> | 2017-06-08 20:48:50 +0200 |
---|---|---|
committer | Arnold Daniels <arnold@jasny.net> | 2017-06-08 20:48:50 +0200 |
commit | afb6318a82f31504410e0a9eaa510dfc546d2e9a (patch) | |
tree | 79e7e4d6f78bf83c0a7dedf89054f7e76545a1c2 | |
parent | 74e5f6da3bec960f3b159d489d72ddd145432a5a (diff) | |
download | router-afb6318a82f31504410e0a9eaa510dfc546d2e9a.zip router-afb6318a82f31504410e0a9eaa510dfc546d2e9a.tar.gz router-afb6318a82f31504410e0a9eaa510dfc546d2e9a.tar.bz2 |
Added some text to the README (WIP)
Added badges to README
-rw-r--r-- | README.md | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -4,6 +4,13 @@ Jasny Router [](http://travis-ci.org/jasny/router) [](https://scrutinizer-ci.com/g/jasny/router/?branch=master) [](https://scrutinizer-ci.com/g/jasny/router/?branch=master) +[](https://insight.sensiolabs.com/projects/a1a1745c-1272-46a3-9567-7bbb52acda5a) +[](https://packagist.org/packages/jasny/router) +[](https://packagist.org/packages/jasny/router) + + +Jasny Router is a versatile PSR-7 compatible router. It decouples the way to determine a route, from the routing and +from running the routed action. The router supports double pass middleware. Installation @@ -14,3 +21,28 @@ composer: composer require jasny/router +Basic Usage +--- + +```php +use Jasny\Router; +use Jasny\Router\Routes\Glob as Routes; +use Jasny\HttpMessage\ServerRequest; +use Jasny\HttpMessage\Response; + +$routes = new Routes([ + '/' => function($request, $response) { + $response->getBody()->write('Hello world'); + return $response; + }, +]); + +$router = new Router($routes); +$router->handle(new ServerRequest()->withGlobalEnvironment(), new Response()); +``` + +Routes +--- + +When creating a `Router`, you need to pass a object that implements the `RoutesInterface`. Routes should be seen as a +collection of routes, with the ability to select one of those routes based on the server request. |