Download the PHP package vagkalosynakis/league-router-attributes without Composer
On this page you can find all versions of the php package vagkalosynakis/league-router-attributes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vagkalosynakis/league-router-attributes
More information about vagkalosynakis/league-router-attributes
Files in vagkalosynakis/league-router-attributes
Package league-router-attributes
Short Description Attribute-based routing for league/route (PHP 8+)
License MIT
Informations about the package league-router-attributes
League Route Attributes
Attribute-based routing for league/route. Define routes using PHP 8 attributes directly on controller methods, eliminating manual route registration boilerplate.
Requirements
- PHP ^8.0
- league/route ^5.1
- psr/container ^1.0|^2.0
Installation
Usage
Basic Routing
Use the #[Route] attribute to declare routes on controller methods:
Route Prefixes and Names
Middleware
Apply middleware at class level (inherited by all methods) or method level:
Excluding Middleware
Use #[WithoutMiddleware] to exclude inherited middleware from specific routes:
Route Discovery
Register routes automatically by scanning a directory:
Manual Registration
Or register specific controllers:
How It Works
The package uses PHP's Reflection API to scan classes for route attributes, then registers them with league/route using its standard API. All league/route features (middleware, route groups, strategies, etc.) work as expected.
Supported HTTP Methods
GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Multiple HTTP Methods
A single route can handle multiple HTTP methods:
Route Parameters
Use league/route's parameter syntax with optional regex constraints:
Architecture
PSR Compliance
- PSR-1: Basic Coding Standard
- PSR-4: Autoloading
- PSR-12: Extended Coding Style
- PSR-11: Container Interface
- PSR-15: HTTP Handlers/Middleware
Testing
### Running Tests ### Test Structure ### Requirements for Testing - PHPUnit ^9.6 - Mockery ^1.5 - PHPStan ^1.10 - PHP CS Fixer ^3.16License
MIT License. See LICENSE file for details.
Contributing
Contributions welcome. Please follow PSR-12 coding standards and ensure tests pass before submitting PRs.
Credits
Built on top of league/route by The PHP League.