PHP code example of grizz-it / micro-router

1. Go to this page and download the library: Download grizz-it/micro-router 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/ */

    

grizz-it / micro-router example snippets




use GrizzIt\MicroRouter\Http\Router;

Router::loadRoutesFromFile('path/to/routes/directory'));



use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

function home(Request $request): Response
{
    return json_response(['id' => $request->get('id')]);
}



use GrizzIt\MicroRouter\Http\Router;

Router::run()->send();

json_response(['type' => 'home']);