Download the PHP package smashed-egg/laravel-route-annotation without Composer
On this page you can find all versions of the php package smashed-egg/laravel-route-annotation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smashed-egg/laravel-route-annotation
More information about smashed-egg/laravel-route-annotation
Files in smashed-egg/laravel-route-annotation
Package laravel-route-annotation
Short Description Adds support for Route Annotations in Laravel
License MIT
Informations about the package laravel-route-annotation
Laravel Route Annotation
This package allows you to load routes using PHP Attributes to define routes in your controller classes.
More details to follow.
Requirements
- PHP 8.0.2+
- Laravel 9.0+
Installation
To install this package please run:
Support Me
Do you like this package? Does it improve you're development. Consider sponsoring to help with future development.
Thank you!
Usage
Registering Routes
To register routes in your controller, first you have to import the Route annotation class:
The Route annotation class takes the following arguments:
- string|null $uri
- string|null $name
- string|null $domain
- array $schemes
- array $defaults
- array $methods
- array $middleware
- array $wheres
- int $priority (Set order of priority for routes, defaults to 0)
Here is an example controller using Route annotations:
Resource Routes
You can configure resource routes by doing the following:
Api Resource Routes
You can configure api resource routes by doing the following:
Loading Routes
Loading routes from a single controller
In your routes file or service provider you can add the following to load routes for a given controller class.
Loading routes from a directory
In your routes file or service provider you can add the following to load routes for a given directory.
You can also wrap them in route groups:
All versions of laravel-route-annotation with dependencies
illuminate/console Version ^9.42|^10.0
illuminate/contracts Version ^9.42|^10.0
illuminate/support Version ^9.42|^10.0