Diagnostic
Diagnostic
Diagnostic controller base class.
class Diagnostic extends \Hazaar\Controller\ActionThis controller provides a common fallback endpoint for diagnostic-style responses and supports multiple response formats (JSON, XML, HTML, text, and Hazaar dump output). It is typically used by internal diagnostics and error-handling flows that need format-aware output from a shared source.
The class also tracks caller context and response code state so subclasses can generate consistent diagnostic payloads across output types.
Properties
code
HTTP status code used by generated diagnostic responses.
protected int $code = 204Defaults to 204 No Content.
caller
protected array $callerMethods
__default
Executes the diagnostic run process.
public __default(string $controllerName, string $actionName): ResponseThis method determines the appropriate response type based on the presence of a response type method or the existence of a 'run' method. If neither is found, it defaults to an HTML response. The response is then wrapped in the appropriate Response object if it is not already an instance of Response.
Parameters
| Parameter | Type | Description |
|---|---|---|
$controllerName | string | |
$actionName | string |
setCaller
public setCaller(array $caller): voidParameters
| Parameter | Type | Description |
|---|---|---|
$caller | array |
setResponseType
Sets the response type for the diagnostic controller.
public setResponseType(ResponseType $type): voidParameters
| Parameter | Type | Description |
|---|---|---|
$type | ResponseType | the type of response to be returned |
json
Returns a JSON response with an error message.
public json(): voidxml
Generates an XML-RPC response.
public xml(): voidThis method creates a SimpleXMLElement with a root element xml and adds a child element data with the content 'NO CONTENT'. It then returns this XML structure wrapped in a Response\XML object.
html
Generates an HTML response with a predefined message.
public html(): voidtext
Returns a text response with the content 'NO CONTENT' and the specified status code.
public text(): voidhazaar
Outputs a diagnostic dump and terminates the script.
public hazaar(): voidThis method sets the HTTP response code to the value of the $code property, outputs a diagnostic message, dumps a placeholder string 'NO CONTENT', prints a backtrace, and then exits the script.
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000