PHP code example of jowy / routing-middleware

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

    

jowy / routing-middleware example snippets


use Zend\Stratigility\MiddlewarePipe;
use Jowy\Routing\Routing;

$app = new MiddlewarePipe();
$route_middleware = new Routing($options);

$app->pipe($route_middleware);

use Pimple\Container;
use Relay\Relay;
use Jowy\Routing\Routing;

$container = new Container();

$container["middleware"] = [
    Routing::class => function() {
        return new Routing($options);
    }
];

$resolver = function ($class) use ($container) {
    return $container[$class];
}

new Relay(array_keys($container["middleware"], $resolver);

    [
        "collection" => function (RouteCollector $collector) {
            $collector->addRoute("GET", "/", function (ServerRequestInterface $req, ResponseInterface $res) {
                return $res;
            });
            $collector->addRoute("GET", "/home", function (ServerRequestInterface $req, ResponseInterface $res) {
                return $res;
            });
        }
    ]
    

    [
        "collection" => function (RouteCollector $collector) {
            $collector->addRoute("GET", "/", "Fully\\Qualified\\ClassName:yourMethod");
        }
    ]
    

    [
        "generator" => new FastRoute\DataGenerator\GroupCountBased();
    ]
    

    [
        "parser" => new FastRoute\RouteParser\Std();
    ]
    

    [
        "dispatcher" => function ($dispatch_data) {
            return new FastRoute\Dispatcher\GroupCountBased($dispatch_data);
        }
    ]
    

    [
        "cache" => true
    ]
    

    [
        "cacheDriver" => new ArrayCache()
    ]