Closure
Closure
Closure-backed controller.
class Closure extends \Hazaar\ControllerExtends: Hazaar\Controller
This controller adapts an arbitrary PHP closure to the framework controller lifecycle. The closure is bound to the controller instance at runtime so it can access controller state and helpers, and its return value is normalized into a framework response type.
Supported closure return values include direct response instances, files, views, arrays/objects/booleans (JSON), and other scalar values (plain text).
Properties
name
Controller type identifier.
protected string $name = 'closure'Type: string
closure
Executable closure used to service incoming action requests.
protected \Closure $closureType: Closure
Methods
__construct
Create a new closure controller.
public __construct(Request $request, \Closure $closure): voidParameters
| Parameter | Type | Description |
|---|---|---|
$request | Hazaar\Application\Request | current application request |
$closure | Closure | closure to execute for this controller |
__default
Executes the closure associated with this controller and returns a Response.
public __default(string $controller, string $action, mixed $actionArgs): ResponseReturns: Hazaar\Controller\Response
Parameters
| Parameter | Type | Description |
|---|---|---|
$controller | string | the name of the controller (not used in this implementation) |
$action | string | the name of the action (not used in this implementation) |
$actionArgs | mixed | the arguments to pass to the closure |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000