Giter VIP home page Giter VIP logo

dispatcher-container's Introduction

Container resolver

This package provides a factory decorator for objects implementing Ellipse\DispatcherFactoryInterface from ellipse/dispatcher package. It allows to produce instances of Ellipse\Dispatcher using middleware and request handler class names.

Require php >= 7.0

Installation composer require ellipse/dispatcher-container

Run tests ./vendor/bin/kahlan

Create a dispatcher factory resolving Psr-15 class names

This package provides an Ellipse\Dispatcher\ContainerResolver class implementing Ellipse\DispatcherFactoryInterface which allows to decorate any other object implementing this interface.

It takes a container implementing Psr\Container\ContainerInterface as first parameter and the factory to decorate as second parameter.

Once decorated, the resulting dispatcher factory can be used to produce instances of Ellipse\Dispatcher by resolving middleware class names as Ellipse\Middleware\ContainerMiddleware from the ellipse/middleware-container package and request handler class names as Ellipse\Handlers\ContainerRequestHandler from the ellipse/handlers-container package.

ContainerMiddleware and ContainerRequestHandler logic is described on the ellipse/middleware-container and ellipse/handlers-container documentation pages.

<?php

namespace App;

use SomePsr11Container;

use Ellipse\DispatcherFactory;
use Ellipse\Dispatcher\ContainerResolver;

// Get some Psr-11 container.
$container = new SomePsr11Container;

// Decorate a DispatcherFactoryInterface implementation with a ContainerResolver.
$factory = new ContainerResolver($container, new DispatcherFactory);

// A dispatcher using both class names and Psr-15 instances can now be created.
$dispatcher = $factory(SomeRequestHandler::class, [SomeMiddleware1::class, new SomeMiddleware2]);

dispatcher-container's People

Contributors

pmall avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.