Download the PHP package deva7mad/lumen-annotations without Composer
On this page you can find all versions of the php package deva7mad/lumen-annotations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download deva7mad/lumen-annotations
More information about deva7mad/lumen-annotations
Files in deva7mad/lumen-annotations
Package lumen-annotations
Short Description Laravel Lumen route and event binding annotations generate
License MIT
Informations about the package lumen-annotations
Lumen Annotations
This package enables annotations in Laravel Lumen to define routes and event bindings.
Installation
Lumen Annotations is distributed as a composer package. So you first have to run the following command
After that copy config/annotations.php
from this package to your configuration directory.
Finally: Add this lines to bootstrap/app.php
file:
Include generated routes
Once you have run php artisan route:scan
(NOTE: see below Examples), you have to include the generated generated.php
file in your bootstrap/app.php
file:
Usage
By using annotations you can define your routes directly in your controller classes and your event bindings directly in your event handlers (see examples for usage of annotations).
Class Annotations
For routes:
Annotation | Description |
---|---|
@Controller |
This annotation must be set to indicate that the class is a controller class. Optional parameters prefix and middleware . |
@Resource |
First parameter is resource name. Optional parameters only and except . |
@Middleware |
First parameter is middleware name. |
For events:
Annotation | Description |
---|---|
@Hears |
This annotation binds an event handler class to an event. |
Method Annotations
For routes:
Annotation | Description |
---|---|
@Get ,br>`@Delete`,@Any |
First parameter is route url. Optional parameters as and middleware . |
@Middleware |
First parameter is middleware name. |
Commands
After you have defined the routes and event bindings via annotations, you have to run the scan command:
- Use
php artisan route:scan
to register all routes. - Use
php artisan route:clear
to clear the registered routes. - Use
php artisan event:scan
to register all event bindings. - Use
php artisan event:clear
to clear the registered events.
Examples
Example #1
Example #2
Example #3
Support
Bugs and feature requests are tracked on GitHub.
Author
- Ahmad Elkenany - Development - Linkedin
License
This package is released under the MIT License.
Support on Beerpay
Hey dude! Help me out for a couple of :beers:!