runner / fastd-fastroute
fastroute for FastD framework
v0.1.4
2019-04-29 02:40 UTC
Requires
- php: ^7.1
- fastd/fastd: ~3.0
- nikic/fast-route: ^1.3
Requires (Dev)
- phpunit/phpunit: ^5.0
This package is auto-updated.
Last update: 2024-10-29 05:34:30 UTC
README
Better Routing
Usage
首先替换框架的服务提供者
\Runner\FastDRoute\RouteServiceProvider::class
组件提供了一个辅助函数 router()
, 会返回 Runner\FastDRoute\Router
实例. 在 config/routes.php
中进行配置路由.
<?php router()->get('/users/{id:\d+}', 'UsersController@show', [ // your middleware ]); router()->group( [ 'prefix' => '/posts', 'middleware' => [ // your middleware ], ], function (\Runner\FastDRoute\Router $router) { $router->get('/{id:\d+}', 'PostsController@show'); router()->put('/{id:\d+}', 'PostController@update'); router()->get('/export', function (\FastD\Http\ServerRequest $request) { return json([ 'foo' => 'bar', ]); }); } );