I’m deep into refactoring an old Kirby 3 site to make it Kirby 5 ready so I’m stumbling across a lot of outdated stuff and broken things. If I get a PHP error displayed in the panel, how do I find the actual source of the problem to fix the underlying issue?
The server responses seem to only include the message as well, but no file or line references. So it’s not just hidden in the output. Any ideas where to look or how to debug this?
@lukaskleinschmidt suggested on Discord to comment out the blueprint definition by definition and I was indeed able to find the error. It was an outdated definition from the early Kirby 3 era.
For reference, this seems to be related:
opened 09:03AM - 23 Apr 26 UTC
needs: decision 🗳
## Description
When a runtime error / exception occurs inside a snippet inside t… he `blocks` folder it does not get logged to the configured php log file.
We have a plugin and if we provoke an error inside a defined route:
```
'routes' => [
[
'pattern' => 'test',
'action' => function () {
dfgfd;
return "test";
}
],
]
```
it correctly gets logged to our php log file:
```
[23-Apr-2026 08:57:43 UTC] Error: Undefined constant "dfgfd" in /var/www/html/kirbycms/site/plugins/myplugin/index.php:77
Stack trace:
#0 [internal function]: Kirby\Http\Route->{closure}()
#1 /var/www/html/kirbycms/vendor/getkirby/cms/src/Http/Router.php(122): Closure->call()
#2 /var/www/html/kirbycms/vendor/getkirby/cms/src/Cms/App.php(343): Kirby\Http\Router->call()
#3 /var/www/html/kirbycms/vendor/getkirby/cms/src/Cms/App.php(1200): Kirby\Cms\App->call()
#4 /var/www/html/kirbycms/public/index.php(22): Kirby\Cms\App->render()
#5 {main}
```
We can also manually log to the error file inside a "blocks" snippet file (`src/kirbycms/site/snippets/blocks/grid.php`):
```
<?php /** @var \Kirby\Cms\Block $block */ ?>
<?php
error_log('my test error');
?>
```
which will be shown in the error log. However, if we add an undefined constant error for example to that snippet:
```
<?php /** @var \Kirby\Cms\Block $block */ ?>
<?php
error_log('my test error');
ssdkfjhsd;
?>
```
it does not get logged! Only the `my test error` is shown in the error log file.
This is a major problem as debugging inside snippets gets expensive to track.
How to enable error logging inside blocks snippets?
EDIT: It seems to affect only snippets which are "blocks" and thus inside the blocks folder (either directly inside `site/snippets/blocks` or inside blocks snippets we register within our plugin. Snippets outside that folder correctly log errors.
**Expected behavior**
The runtime error should be logged.
## To reproduce
1. Provoke a syntax error or undefined constant error inside a php section of a block snippet php file and let that file render.
2. The frontend does not render the respective cms block and silently fails. It also does not show a rendered html error page.
3. Look in the configured php error file to find that the exception is not shown there.
## Your setup
**Kirby Version**
5.2.2
**Your system (please complete the following information)**
- Device: Desktop
- OS: Arch Linux / Ubuntu inside Docker running apache with php-fpm
- Browser: Any Browser
- Version: Any Browser version
**Context Information**
`debug` mode is set to true inside `site/config.php`