Diagnostic
Diagnostic
Diagnostic controller base class.
class Diagnostic extends \Hazaar\Controller\ActionExtends: Hazaar\Controller\Action
This 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 = 204Type: int
Defaults to 204 No Content.
caller
protected array $callerType: array
Methods
__default
Executes the diagnostic run process.
public __default(string $controllerName, string $actionName): ResponseReturns: Hazaar\Controller\Response
This 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): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$caller | array |
setResponseType
Sets the response type for the diagnostic controller.
public setResponseType(ResponseType $type): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$type | Hazaar\Controller\Enums\ResponseType | the type of response to be returned |
json
Returns a JSON response with an error message.
public json(): Response\JSONReturns: Hazaar\Controller\Response\JSON
xml
Generates an XML-RPC response.
public xml(): Response\XMLReturns: Hazaar\Controller\Response\XML
This 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(): Response\HTMLReturns: Hazaar\Controller\Response\HTML
text
Returns a text response with the content 'NO CONTENT' and the specified status code.
public text(): Response\TextReturns: Hazaar\Controller\Response\Text
hazaar
Outputs a diagnostic dump and terminates the script.
public hazaar(): voidReturns: void
This 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 Fri, 04 Sep 2026 23:32:16 +0000