1. Go to this page and download the library: Download ellipse/handlers-container 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-container example snippets
namespace App;
use SomePsr11Container;
use Ellipse\Handlers\ContainerRequestHandler;
// Get some Psr-11 container.
$container = new SomePsr11Container;
// Add a request handler in the container.
$container->set('some.request.handler', function () {
return new SomeRequestHandler;
});
// Create a container request handler with the Psr-11 container and the entry id.
$handler = new ContainerRequestHandler($container, 'some.request.handler');
// The handler ->handle() method retrieve the request handler from the container and proxy it.
$response = $handler->handle($request);
namespace App;
use Psr\Http\Server\RequestHandlerInterface;
use SomePsr11Container;
use Ellipse\Container\ReflectionContainer;
use Ellipse\Handlers\ContainerRequestHandler;
// Get some Psr-11 container.
$container = new SomePsr11Container;
// Decorate the container with a reflection container.
// Specify the request handler implementations can be auto wired.
$reflection = new ReflectionContainer($container, [
RequestHandlerInterface::class,
]);
// Create a container request handler with the reflection container and a request handler class name.
$handler = new ContainerRequestHandler($reflection, SomeRequestHandler::class);
// An instance of SomeRequestHandler is built and its ->handle() method is proxied.
$response = $handler->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.