# debug

Enables/disables PHP errors

****

****

A quick way to turn on/off PHP errors.

```php
return [
    'debug'  => true
];
```

<alert>
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.
</alert>

(screencast: https://www.youtube.com/watch?v=GrBbuwRSuMA title: Debug mode text: Kirby's debug mode is super helpful for finding mistakes in your templates, snippets or other parts of your project.)

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 in the config for your local/staging setup, see <a href="https://getkirby.com/docs/guide/configuration#multi-environment-setup">Multiple config files</a>
- Use conditions for the `debug` option in `config.php`, e.g. based on server name or logged in users
    ```php
    'debug' => str_ends_with($_SERVER['SERVER_NAME'] ?? '', '.test') || @$_SERVER['SERVER_NAME'] === 'localhost', // enable debug for domains that end on ".test"
    ```

    ```php
    'ready' => function ($kirby) {
        return [
            'debug' => kirby()->user() && kirby()->user()->role()->isAdmin()
        ];
    }
    ```

See also: <a href="https://getkirby.com/docs/cookbook/php/debugging-basics">Debugging basics</a>