This Composer package simplifies route management in your PHP applications by allowing the use of PHP attributes to define routes in an elegant and expressive way. It streamlines the setup of custom routes, enabling developers to define routing rules that are clear and intuitive.
- Define routes using PHP attributes: enhancing code readability and maintainability.
- Flexible handling of route parameters and URL constraints.
- Seamless integration with popular PHP frameworks.
- Route group management for hierarchical organization of routes.
- Middleware support for advanced request processing customization.
- Comprehensive documentation and usage examples for quick adoption.
You can install this package via Composer:
composer require ugo-brocard/router
Here's a basic example of how to use this package to define a route using PHP attributes:
use Router\Attributes\{Route, Get, Post}
/**
* Class MyController
*
* @package Application\Controllers
*/
#[Route("/route-group")]
final class MyController
{
#[Get("/route")]
public function myAction(): string
{
// (...)
}
#[Post("/route")]
public function yetAnotherAction(): int
{
// (...)
}
}
For detailed documentation and usage examples, please refer to our documentation.
This project is licensed under the MIT License.
This package was developed and maintained by Ugo Brocard.
I'd like to express my gratitude to the open-source community for their contributions and inspirations