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 ({@see self::exitWithError()}).
- Render and terminate with framework exceptions ({@see self::exitWithException()}).
- Handle uncaught throwables with environment-appropriate fatal output ({@see self::fatal()}).
- Provide a trace helper for manual debugging ({@see self::trace()}).
Response behavior:
- If the response type header indicates a stream, errors are sent using {@see Stream}.
- Otherwise, an {@see 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): neverParameters
| Parameter | Type | Description |
|---|---|---|
$error | array |
exitWithException
This function handles errors and terminates the script execution.
public exitWithException(Exception $exception): neverParameters
| Parameter | Type | Description |
|---|---|---|
$exception | Exception |
fatal
Terminates the script execution and displays an error message.
public fatal(\Throwable $err, bool $forceTextOnly): neverThis 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(): neverThis 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 Tue, 21 Apr 2026 04:00:25 +0000