Download the PHP package ellipse/dispatcher-controller without Composer
On this page you can find all versions of the php package ellipse/dispatcher-controller. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ellipse/dispatcher-controller
More information about ellipse/dispatcher-controller
Files in ellipse/dispatcher-controller
Package dispatcher-controller
Short Description Psr-15 middleware dispatcher factory resolving controller definitions
License MIT
Homepage https://github.com/ellipsephp/dispatcher-controller
Informations about the package dispatcher-controller
Controller 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 controller definitions.
Require php >= 7.0
Installation composer require ellipse/dispatcher-controller
Run tests ./vendor/bin/kahlan
- Create a dispatcher factory resolving controller definitions
- Controller definitions
Create a dispatcher factory resolving controller definitions
This package provides an Ellipse\Dispatcher\ControllerResolver
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 ellipse/handlers-controller package.
Controller definitions
An instance of ControllerRequestHandler
needs the container entry id of an object used as controller, a method name and an optional array of request attribute names. A controller definition defines which controller class, method name and request attributes should be used by the ControllerRequestHandler
. It is an array with at least two string elements:
- The first one is the controller fully qualified class name
- The second one is the name of the controller method to execute prepended with
'@'
- The optional third element is an array of strings representing names of the request attributes to use as parameters when calling the controller method
For example [SomeController::class, '@index']
and [SomeController::class, '@show', ['some_id']]
are valid controller definitions. The first one execute the SomeController
class ->index()
method and the second one execute its ->show($id)
method using the value of the request attribute named 'some_id'
as parameter.
This array notation was prefered over a string like 'SomeController@index'
so there is no need to deal with controller namespaces. Also the method name start with a '@'
because [SomeController::class, 'index']
is considered as a callable by php, even when the index method is not static!
ControllerRequestHandler
logic is described on the ellipse/handlers-controller documentation page.
All versions of dispatcher-controller with dependencies
psr/container Version ^1.0
psr/http-message Version ^1.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
ellipse/dispatcher Version ^1.6
ellipse/handlers-controller Version ^1.0
ellipse/container-overridden Version ^1.0
ellipse/resolvable-callable Version ^1.0.3