mini\Controller\Router::importRoutesFromAttributes()
Method
public
Signature
public function importRoutesFromAttributes(object $controller): void
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$controller |
object |
required | Documentation missing |
Returns
void
Documentation
Import routes from controller method attributes
Scans the provided object for methods with Route attributes (#[GET], #[POST], #[Route], etc.) and automatically registers them.
Example:
class UserController extends AbstractController {
public function __construct() {
parent::__construct();
$this->router->importRoutesFromAttributes($this);
}
#[GET('/')]
public function index(): ResponseInterface { ... }
#[POST('/')]
public function create(): ResponseInterface { ... }
}