Closure
Less than 1 minute
Closure
Closure-backed controller.
class Closure extends \Hazaar\Controller\ControllerThis 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 (JSON), and scalar values (plain text).
Properties
name
Controller type identifier.
protected string $name = 'closure'public $Methods
__construct
Create a new closure controller.
public __construct(Request $request, \Closure $closure): voidParameters
| Parameter | Type | Description |
|---|---|---|
$request | 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): ResponseParameters
| 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 Tue, 21 Apr 2026 04:00:24 +0000