PHP code example of andyvanee / miniroute

1. Go to this page and download the library: Download andyvanee/miniroute 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/ */

    

andyvanee / miniroute example snippets


namespace MyApp\Controller;

class HomeController {
    public function __construct($container) {
        // Setup anything that is common to all routes in this controller
    }
    public function index($request, $response) {
        // Handle this route
    }
}



$app = new MiniRoute\MiniRoute;
;

$app->register('helloservice', function() {
    return 'Hello Service';
});

use MyApp\Controller\HomeController;
$app->route('GET', '/', [HomeController::class, 'index']);