PHP code example of runner / fastd-fastroute

1. Go to this page and download the library: Download runner/fastd-fastroute library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

runner / fastd-fastroute example snippets


\Runner\FastDRoute\RouteServiceProvider::class



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