FastRoute For FastD, or FFF 🔥💑🔥
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.travis.yml
CHANGELOG.md
README.md
composer.json
phpunit.xml.dist

README.md

FastRoute For FastD

Better Routing

StyleCI

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',
            ]);
        });
    }
);