PHP code example of caridea / dispatch

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

    

caridea / dispatch example snippets


$request = new \Zend\Diactoros\ServerRequest();
// I generally use zend-diactoros, but feel free to use whatever PSR-7 library you use

$middleware = [
    // your custom \Psr\Http\Server\MiddlewareInterface objects
];
$runner = new \Caridea\Dispatch\Runner($middleware);
$response = $runner->handle($request);

$response = new \Zend\Diactoros\Response();
$runner = new \Caridea\Dispatch\Runner($middleware, $response);
$response = $runner->handle($request);

$runner = new \Caridea\Dispatch\Runner($middleware);
$response1 = $runner->handle($request);
$response2 = $runner->handle($request);

$middleware = [
    // your custom \Psr\Http\Server\MiddlewareInterface objects.
    // Any that implement Prioritized will get run in priority order,
    // Any others get run last, in insert order.
];
$runner = new \Caridea\Dispatch\PriorityRunner($middleware);

$middleware = new \Caridea\Dispatch\Middleware\PriorityDelegate($middleware, 123456);