Group
Group
Properties
router
private Router $routerprefix
private string $prefixroutes
private array $routesMethods
__construct
public __construct(Router $router, string $prefix): voidParameters
| Parameter | Type | Description |
|---|---|---|
$router | Router | |
$prefix | string |
middleware
Applies a middleware to the route group.
public middleware(string $middleware, mixed $args): selfThis method iterates over all routes currently registered in the group and applies the specified middleware to each of them.
Parameters
| Parameter | Type | Description |
|---|---|---|
$middleware | string | the middleware to apply, either as a string or an instance |
$args | mixed |
addRoute
Adds a route to the group.
public addRoute(Route $route): voidThis method adds a route instance to the group's internal list of routes. It also applies the group's path prefix to the route and registers the route with the main router.
Parameters
| Parameter | Type | Description |
|---|---|---|
$route | Route | the route instance to add to the group |
get
Registers a route that responds to HTTP GET requests.
public get(string $path, mixed $callable, array $actionArgs): RouteParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | the URL path for the route |
$callable | mixed | the callback or controller action to handle the request |
$actionArgs | array | optional action arguments for the route |
post
Registers a route that responds to HTTP POST requests.
public post(string $path, mixed $callable, array $actionArgs): RouteParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | the URL path for the route |
$callable | mixed | the callback or controller method to handle the request |
$actionArgs | array | optional action arguments for the route |
put
Registers a route that responds to HTTP PUT requests.
public put(string $path, mixed $callable, array $actionArgs): RouteParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | the URI path that the route will respond to |
$callable | mixed | the handler for the route, which can be a callable or other valid route handler |
$actionArgs | array | optional action arguments for the route |
delete
Registers a route that responds to HTTP DELETE requests.
public delete(string $path, mixed $callable, array $actionArgs): RouteParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | the URL path that the route should match |
$callable | mixed | the callback or controller action to be executed when the route is matched |
$actionArgs | array | optional action arguments for the route |
patch
Registers a route that responds to HTTP PATCH requests.
public patch(string $path, mixed $callable, array $actionArgs): RouteParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | the URI path that the route will match |
$callable | mixed | the callback or controller action to be executed when the route is matched |
$actionArgs | array | optional action arguments for the route |
options
Registers a route that responds to HTTP OPTIONS requests.
public options(string $path, mixed $callable, array $actionArgs): RouteParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | the URL path to match |
$callable | mixed | the callback or controller action to handle the request |
$actionArgs | array | optional action arguments for the route |
any
Registers a route that responds to any HTTP method.
public any(string $path, mixed $callable, array $actionArgs): RouteParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | the path pattern to match |
$callable | mixed | the callback to execute when the route is matched |
$actionArgs | array | optional action arguments for the route |
group
Groups routes under a common URL prefix.
public group(string $prefix, \Closure $callback): GroupThis method allows you to group multiple route definitions that share a common URL path prefix. The provided callback function will be executed with the router instance, allowing routes defined within to inherit the prefix logic (though currently the prefix appears unused in this implementation).
Parameters
| Parameter | Type | Description |
|---|---|---|
$prefix | string | the URL prefix for the grouped routes |
$callback | \Closure | a callback function that receives the Router instance |
auth
Applies authentication to all routes within the group.
public auth(?Adapter $adapter, mixed $args): RouteInterfaceIf an authentication adapter is provided, it will be used for all routes. Otherwise, the default adapter will be used.
Parameters
| Parameter | Type | Description |
|---|---|---|
$adapter | Adapter | optional authentication adapter to use |
$args | mixed |
getPath
Get the full path for the route group, optionally appending a suffix.
private getPath(?string $suffix): stringThis method combines the group's prefix with a provided suffix to form a complete path. If no suffix is provided, it returns the prefix alone. It ensures that there are no double slashes where the prefix and suffix join.
Parameters
| Parameter | Type | Description |
|---|---|---|
$suffix | string | An optional path segment to append to the group prefix. Any leading slashes will be trimmed. |
Generated by Hazaar API Doc Generator on Sun, 01 Mar 2026 09:22:26 +0000