Error Handling

HexPHP includes a native, Ignition-style error handling screen that intercepts and beautifully formats exceptions, fatal errors, and general warnings.

Debug Mode

The display behavior is strictly controlled by your .env file to ensure absolutely no sensitive information is leaked in production environments.

Development (.env)
APP_DEBUG=true

When APP_DEBUG=true, you get the beautiful trace page mapping all variables and file lines.

Production (.env)
APP_DEBUG=false

When APP_DEBUG=false, developers only see a generic 500 error page served by the ErrorController, protecting stack traces from the public.

The ExceptionHandler API

HexPHP automatically boots the \App\Core\ExceptionHandler directly in public/index.php natively handling three states:

  • Exceptions: Native interception using set_exception_handler().
  • Warnings / Notices: Automatically upgraded to native \ErrorException via set_error_handler() allowing for complete consistency.
  • Unrecoverable Fatals: Native syntax and out-of-memory errors caught using register_shutdown_function() safely converting them to visual traces.

Testing Exceptions

Testing exception pages is simple. You can manually throw inside any controller:

throw new \Exception("This is a simulated failure.");