Shutdown
Shutdown
Centralized fatal shutdown/error termination handler for the application.
class ShutdownThis utility class provides static exit paths used during unrecoverable failures, ensuring the framework emits a consistent error response for both HTTP and CLI execution contexts.
Responsibilities:
- Convert raw PHP error arrays into framework error responses (Hazaar\Application\Shutdown::exitWithError).
- Render and terminate with framework exceptions (Hazaar\Application\Shutdown::exitWithException).
- Handle uncaught throwables with environment-appropriate fatal output (Hazaar\Application\Shutdown::fatal).
- Provide a trace helper for manual debugging (Hazaar\Application\Shutdown::trace).
Response behavior:
- If the response type header indicates a stream, errors are sent using Hazaar\Controller\Response\Stream.
- Otherwise, an Hazaar\Application instance and configured error controller are used to render a standard framework error response.
- CLI fatal errors emit plain text output, while web requests use HTTP status and fatal templates.
Methods
exitWithError
public exitWithError(array $error): neverReturns: never
Parameters
| Parameter | Type | Description |
|---|---|---|
$error | array |
exitWithException
This function handles errors and terminates the script execution.
public exitWithException(Exception $exception): neverReturns: never
Parameters
| Parameter | Type | Description |
|---|---|---|
$exception | Hazaar\Exception |
fatal
Terminates the script execution and displays an error message.
public fatal(\Throwable $err, bool $forceTextOnly): neverReturns: never
This function is used to handle errors and terminate the script execution. It clears the output buffer, sets the HTTP response code to 500, and displays an error message with the provided error information.
Parameters
| Parameter | Type | Description |
|---|---|---|
$err | Throwable | the error information to be displayed |
$forceTextOnly | bool |
trace
Traces the current execution and terminates the script.
public trace(): neverReturns: never
This function generates a backtrace of the current execution and includes a trace file for debugging purposes. After generating the trace, it terminates the script using the exit function.
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000