PHP code example of ellipse / dispatcher-callable

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

    

ellipse / dispatcher-callable example snippets




namespace App;

use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;

use Ellipse\DispatcherFactory;
use Ellipse\Dispatcher\CallableResolver;

// Decorate a DispatcherFactoryInterface implementation with a CallableResolver.
$factory = new CallableResolver(new DispatcherFactory);

// This callable acts as a middleware.
$middleware = function (ServerRequestInterface $request, RequestHandlerInterface $handler) {

    // ...

}

// This callable acts as a request handler.
$handler = function (ServerRequestInterface $request) {

    // ...

}

// A dispatcher using both callables and Psr-15 instances can now be created.
$dispatcher = $factory($handler, [$middleware, new SomeMiddleware]);