|
1 | | -# BitFrame\Router\FastRouteRouter |
| 1 | +# BitFrame\FastRoute |
| 2 | + |
| 3 | +[](https://codecov.io/gh/designcise/bitframe-fastroute) |
| 4 | +[](https://travis-ci.org/designcise/bitframe-fastroute) |
2 | 5 |
|
3 | 6 | FastRoute wrapper class to manage http routes as a middleware. |
4 | 7 |
|
5 | | -### Installation |
| 8 | +## Installation |
| 9 | + |
| 10 | +Install using composer: |
6 | 11 |
|
7 | | -See [installation docs](https://www.bitframephp.com/middleware/router/fastroute) for instructions on installing and using this middleware. |
| 12 | +``` |
| 13 | +$ composer require designcise/bitframe-fastroute |
| 14 | +``` |
8 | 15 |
|
9 | | -### Usage Example |
| 16 | +Please note that this package requires PHP 7.4.0 or newer. |
| 17 | + |
| 18 | +## Usage Example |
10 | 19 |
|
11 | 20 | ``` |
12 | | -use \BitFrame\Router\FastRouteRouter; |
| 21 | +use BitFrame\App; |
| 22 | +use BitFrame\Emitter\SapiEmitter; |
| 23 | +use BitFrame\FastRoute\Router; |
13 | 24 |
|
14 | 25 | require 'vendor/autoload.php'; |
15 | 26 |
|
16 | | -$app = new \BitFrame\Application; |
| 27 | +$app = new App(); |
| 28 | +$router = new Router(); |
17 | 29 |
|
18 | | -$app->map(['GET', 'POST'], '/test', function ($request, $response, $next) { |
| 30 | +$router->map(['GET', 'POST'], '/test', function ($request, $handler) { |
| 31 | + $response = $handler->handle($request); |
19 | 32 | $response->getBody()->write('Test Page'); |
20 | | - |
21 | 33 | return $response; |
22 | 34 | }); |
23 | 35 |
|
24 | 36 | $app->run([ |
25 | | - /* In order to output response from the router (or router middleware), |
26 | | - * make sure you include a response emitter middleware, for example: |
27 | | - * \BitFrame\Message\DiactorosResponseEmitter::class, */ |
28 | | - // router should normally be the last middleware to run |
29 | | - FastRouteRouter::class |
| 37 | + SapiEmitter::class, |
| 38 | + $router, |
| 39 | + // ... |
30 | 40 | ]); |
31 | 41 | ``` |
32 | 42 |
|
33 | | -### Tests |
| 43 | +## Tests |
| 44 | + |
| 45 | +To run the tests you can use the following commands: |
34 | 46 |
|
35 | | -To execute the test suite, you will need [PHPUnit](https://phpunit.de/). |
| 47 | +| Command | Type | |
| 48 | +| ---------------- |:---------------:| |
| 49 | +| `composer test` | PHPUnit tests | |
| 50 | +| `composer style` | CodeSniffer | |
| 51 | +| `composer md` | MessDetector | |
| 52 | +| `composer check` | PHPStan | |
36 | 53 |
|
37 | | -### Contributing |
| 54 | +## Contributing |
38 | 55 |
|
39 | 56 | * File issues at https://github.com/designcise/bitframe-fastroute/issues |
40 | 57 | * Issue patches to https://github.com/designcise/bitframe-fastroute/pulls |
41 | 58 |
|
42 | | -### Documentation |
43 | | - |
44 | | -Documentation is available at: |
| 59 | +## Documentation |
45 | 60 |
|
46 | | -* https://www.bitframephp.com/middleware/router/fastroute/ |
| 61 | +Complete documentation for v2.0 will be available soon. |
47 | 62 |
|
48 | | -### License |
| 63 | +## License |
49 | 64 |
|
50 | 65 | Please see [License File](LICENSE.md) for licensing information. |
0 commit comments