Download the PHP package nicc0/slim-annotation-router without Composer
On this page you can find all versions of the php package nicc0/slim-annotation-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nicc0/slim-annotation-router
More information about nicc0/slim-annotation-router
Files in nicc0/slim-annotation-router
Package slim-annotation-router
Short Description Slim Annotation Router for Slim 4
License MIT
Homepage https://github.com/nicc0/slim-annotation-router
Informations about the package slim-annotation-router
Slim-Annotation-Router
Annotation Router for Slim 4.x
Installation
It's recommended using Composer to install Slim Annotation Router.
This will install Slim Annotation Router and all required dependencies. Remember Slim 4.x requires PHP 7.1 or newer.
Usage
Creating Routes by Annotation
By opening the url http://your_site_url/example/hello, you should see "Hello world!".
Adding Middlewares to contoller by Annotation
To add Middleware to Controller or Action use @Middleware("")
annotation, which pass the name of Middleware.
It is important to know that the name we pass must be defined in the Container. Name passes as the third parameter in the AnnotationRouteCollector
constructor. It is also important that the added Middleware must implements of MiddlewareInterface
otherwise Middleware will not be added to the Route.
There is also possibility to add more than one Middleware to Controller or Action.
For example, we have to add AuthMiddleware to controller. Firstly we have to define AuthMiddleware in Container.
If Middleware exists in our Container, now we can use middleware annotation by adding @Middleware("authMiddleware")
to controller.
Tests
To execute the test suite, you'll need to install all development dependencies.
License
The Slim Annotation Router is licensed under the MIT license. See License File for more information.