PHP code example of hannesvdvreken / route-middleware

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

    

hannesvdvreken / route-middleware example snippets


use League\Route\RouteCollection;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\RequestInterface;

$router = new RouteCollection();

// Setup router
$router->addRoute('GET', '/robots.txt', function (RequestInterface $request, ResponseInterface $response) {
    // Adjust the response
    return $response;
});

$app = new League\Route\Stack\Middleware($router);

$response = $app->handle($request);