Skip to content

Kirby 5.6.4

debug

Enables/disables detailed error messages

A quick way to turn on/off detailed error messages.

/site/config/config.php
return [
    'debug' => true
];

In debug mode, Kirby shows you what went wrong:

  • PHP errors and uncaught exceptions on your site open the Whoops error page with the stack trace. Without debug mode, visitors see a short error page, which you can replace with the fatal option.
  • Error responses of the REST API include the exception class, file and line.
  • Errors in block snippets are thrown instead of rendering an empty block.
  • Deprecated features trigger deprecation warnings.

Make sure to disable debug mode in production! Displaying PHP errors on a public server can be a serious security risk:

  • Error messages are displayed with detailed information about the code structure (e.g. file path, class, method)
  • With Whoops enabled, there will be even more detailed information about the code structure

In a production environment, always log errors to your PHP error logs.

Screencast

Debug mode

Kirby's debug mode is super helpful for finding mistakes in your templates, snippets or other parts of your project.

This video is loaded from YouTube servers with your consent. Read more…

To avoid accidentally enabling debugging in production, but to still be able to use it in certain situations, you have different options:

  • Disable debug in config.php and only enable it in the config for your local/staging setup, see Multiple config files

  • Use conditions for the debug option in config.php, e.g. based on server name or logged in users

    'debug' => str_ends_with($_SERVER['SERVER_NAME'] ?? '', '.test') || @$_SERVER['SERVER_NAME'] === 'localhost', // enable debug for domains that end on ".test"
    'ready' => function ($kirby) {
          return [
              'debug' => $kirby->user()?->isAdmin() === true
          ];
      }

Set the editor option to open the files from error messages right in your code editor.

See also: Debugging and Debugging basics