PHP code example of veka-server / dispatcher

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

    

veka-server / dispatcher example snippets


// creation du dispatcher
$Dispatcher = new VekaServer\Dispatcher\Dispatcher();

// ajout des middlewares
$Dispatcher
    ->pipe(new \Middlewares\Whoops())
    ->pipe(new VK\Framework\MyMiddleware())
    ->pipe(new VK\Framework\MyMiddlewareA());

// recuperation de la requete recue
$request = \GuzzleHttp\Psr7\ServerRequest::fromGlobals();

// lance l'execution des middlewares et recupere la reponse
$response = $Dispatcher->process($request);

// si la reponse est presente ont l'affiche
if($response instanceof \Psr\Http\Message\ResponseInterface)
    $Dispatcher->send($response);