Basic
Basic
Basic controller class
This controller is a basic controller for directly handling requests. Developers can extend this class to create their own flexible controllers for use in modern AJAX enabled websites that don't require HTML views.
How it works is a request is passed to the controller and the controller is responsible for processing it, creating a new response object and return that object back to the application for processing.
This controller type is typically used for handling AJAX requests as responses to these requests do not require rendering any views. This allows AJAX requests to be processed quickly without the overhead of rendering a view that will never be displayed.
Properties
stream
protected bool $stream
Methods
initialize
public initialize(Request $request): ?Response
Parameters
Parameter | Type | Description |
---|---|---|
$request | Request |
runAction
Run an action method on a controller.
public runAction(string $actionName, array $actionArgs = [], bool $namedActionArgs = false): Response
This is the main controller action decision code and is where the controller will decide what to actually execute and whether to cache the response on not.
Parameters
Parameter | Type | Description |
---|---|---|
$actionName | string | |
$actionArgs | array | The arguments to pass to the action |
$namedActionArgs | bool |
stream
Sends a stream response to the client.
public stream(string $value): bool
This method sends a stream response to the client, allowing the client to download the response as a file. It sets the necessary headers for the response and flushes the output buffer to ensure the response is sent immediately.
Parameters
Parameter | Type | Description |
---|---|---|
$value | string | The value to be streamed. If an array is provided, it will be |
converted to a JSON string before streaming. |
init
protected init(Request $request): void
Parameters
Parameter | Type | Description |
---|---|---|
$request | Request |
initResponse
protected initResponse(Request $request): ?Response
Parameters
Parameter | Type | Description |
---|---|---|
$request | Request |
Generated by Hazaar API Doc Generator