PHP code example of idiosyncratic / http-router

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

    

idiosyncratic / http-router example snippets


  /**
   * @throws Idiosyncratic\Http\Exception\Client\NotFound
   * @throws Idiosyncratic\Http\Exception\Client\MethodNotAllowed
   */
  public function findRoute(ServerRequestInterface $request) : Idiosyncratic\Http\Router\Route;
  

$container = new League\Container\Container();

$container->add(ServerRequestInterfaceImplementation::class);

$routes = new Idiosyncratic\Http\Router\RouteGroup();

$routes->addRoute('/hello', ServerRequestInterfaceImplementation::class, 'GET', 'POST');

$router = new Idiosyncratic\Http\Router\Router($routes, $container);

// Create instance of Psr\Http\Message\ServerRequestInterface...

$response = $router->handle($serverRequest);