Route
Route
Properties
router
public Router $routercallable
private mixed $callablepath
public string $pathresponseType
private int $responseType = 'Response'methods
private array $methodsactionArgs
private array $actionArgscallableParameters
private array $callableParametersmiddleware
private array $middlewareMethods
__construct
public __construct(?string $path, array $methods): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$methods | array |
setCallable
Sets the callable for the route and processes its reflection.
public setCallable(mixed $callable): voidParameters
| Parameter | Type | Description |
|---|---|---|
$callable | mixed | The callable to be set. It can be a closure, an array with a class and method, or a reflection method. |
setRouter
Sets the router instance for the application.
public setRouter(Router $router): voidParameters
| Parameter | Type | Description |
|---|---|---|
$router | Router | the router instance to be set |
getPath
Retrieves the path associated with the current route.
public getPath(): ?stringMatches the given HTTP method and path against the route's method and path.
public (string $method, string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$method | string | The HTTP method to match (e.g., 'GET', 'POST'). |
$path | string | the request path to match |
getControllerClass
public getControllerClass(): stringgetControllerName
public getControllerName(): stringgetController
Retrieves the controller instance based on the callable property.
public getController(): ?ControllerThis method checks if the callable property is a Closure or an array. If it is a Closure, it returns a new Closure instance. If it is an array, it extracts the controller class name, verifies its existence, and returns a new instance of the controller class.
getAction
Retrieves the action to be executed.
public getAction(): stringThis method checks if the action is defined in the callable array. If it is, it returns that action. Otherwise, it falls back to the default action specified in the router configuration.
getActionArgs
Retrieve the action arguments.
public getActionArgs(): voidThis method returns an array of arguments that are passed to the action.
getResponseType
Retrieves the response type of the route.
public getResponseType(): intprefixPath
Prefixes the path of the route with the given path.
public prefixPath(string $path): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | the path to be prefixed |
middleware
Adds middleware(s) to the route.
public middleware(string $middleware, mixed $args): selfAccepts a string of middleware names separated by colons and merges them into the existing middleware array.
Parameters
| Parameter | Type | Description |
|---|---|---|
$middleware | string | Middleware name(s), separated by colons (e.g., 'auth:logging'). |
$args | mixed |
getMiddlewareHandlers
Retrieves the list of middleware associated with the route.
public getMiddlewareHandlers(): voidGenerated by Hazaar API Doc Generator on Mon, 27 Oct 2025 13:01:29 +0000