Utility class for standardizing JSON HTTP responses.
More...
|
| static | json (array $data, int $statusCode=200) |
| | Sends a successful JSON response and terminates execution.
|
| |
| static | error (string $message, int $statusCode=400, $details=null) |
| | Sends an error JSON response and either throws an exception (in CLI) or terminates execution.
|
| |
Utility class for standardizing JSON HTTP responses.
◆ error()
| static App\Core\Response::error |
( |
string | $message, |
|
|
int | $statusCode = 400, |
|
|
| $details = null ) |
|
static |
Sends an error JSON response and either throws an exception (in CLI) or terminates execution.
- Parameters
-
| string | $message | The error message to display. |
| int | $statusCode | HTTP status code (default: 400). |
| mixed | $details | Additional debugging information. |
- Exceptions
-
Exception When running in CLI mode (PHPUnit compatibility).
◆ json()
| static App\Core\Response::json |
( |
array | $data, |
|
|
int | $statusCode = 200 ) |
|
static |
Sends a successful JSON response and terminates execution.
- Parameters
-
| array | $data | The payload to return. |
| int | $statusCode | HTTP status code (default: 200). |
The documentation for this class was generated from the following file: