1. Go to this page and download the library: Download ellipse/handlers 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 / handlers example snippets
namespace App;
use Ellipse\Handlers\FallbackRequestHandler;
// Get some fallback Psr-7 response, here with a 404 status code.
$response = some_psr7_response_factory()->withStatus(404);
// Create a fallback request handler returning the response.
$fallback = new FallbackRequestHandler($response);
// The response is returned.
$response = $fallback->handle($request);
namespace App;
use Ellipse\Handlers\FallbackRequestHandler;
use Ellipse\Handlers\RequestHandlerWithMiddleware;
// create Psr-15 middleware and request handler.
$middleware = new SomeMiddleware;
$handler = new FallbackRequestHandler($response);
// Wrap the middleware around the request handler.
$decorated = new RequestHandlerWithMiddleware($handler, $middleware);
// The request goes through the middleware then hit the fallback request handler.
$response = $decorated->handle($request);
namespace App;
use Ellipse\Handlers\FallbackRequestHandler;
use Ellipse\Handlers\RequestHandlerWithMiddlewareStack;
// create Psr-15 middleware and request handler.
$middleware1 = new SomeMiddleware1;
$middleware2 = new SomeMiddleware2;
$handler = new FallbackRequestHandler($response);
// Wrap the middleware around the request handler in LIFO order.
$decorated = new RequestHandlerWithMiddlewareStack($handler, [
$middleware2,
$middleware1,
]);
// The request goes through middleware1, middleware2, then hit the fallback request handler.
$response = $decorated->handle($request);
namespace App;
use Ellipse\Handlers\FallbackRequestHandler;
use Ellipse\Handlers\RequestHandlerWithMiddlewareQueue;
// create Psr-15 middleware and request handler.
$middleware1 = new SomeMiddleware1;
$middleware2 = new SomeMiddleware2;
$handler = new FallbackRequestHandler($response);
// Wrap the middleware around the request handler in FIFO order.
$decorated = new RequestHandlerWithMiddlewareQueue($handler, [
$middleware1,
$middleware2,
]);
// The request goes through middleware1, middleware2, then hit the fallback request handler.
$response = $decorated->handle($request);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.