Debugging features
While you’re building your website, it’s a good idea to enable the “debug” mode in some occasions:
- It gets rid of the caching features, which can sometimes force you to refresh your web-browser frenetically to get the very latest version of a page you changed a second ago.
- It shows you the real error messages, complete with file paths and stack traces, instead of showing you sugar-coated error messages that don’t give any technical details most visitors don’t care about.
- It can show you a debug window on top of your website (we’ll get back to this in a bit).
There are 2 ways to enable “debug” mode:
- Append
?!debugat the end of the URL. For example, go tohttp://domain.com/about?!debug. - Initialize the
PieCrustengine with aarray('debug' => true)parameter.
When “debug” mode is enabled, all links generated with the pcurl family of
template functions have the ?!debug suffix so that you stay in “debug” mode
even after following internal links.
Debug window
A debug window can be inserted in your templates with piecrust.debug_info.
When not in “debug” mode, that template macro just returns nothing, so you can
add it in all your templates. Note that you may need to escape it, since it
contains HTML code.
For example, with Twig, you would add the following code somewhere in your page
or template (most probably just before the ending </body> tag):
{{ piecrust.debug_info|raw }}
The debug window contains a lot of useful information about the current page, like the cache status or the available template variables.