Your way to remember debug mode is still active? 😂

Hey… i think, i’m not the only one who sometimes forgets to set debug mode to false again…
do you have any solution for a reminder?

i think of something like a cronjob that checks debug-state to remind me…
and/or showing status in kirby-panel… maybe by a special background color of the status line… or something like that…

How do you remind yourself? =)

I’m with You @demlak! :wink:
Actually it’s pretty easy and a no-brainer with two config files.

Set Your debug options to true in the local config file, i.e. config.localhost.php

and set it to false in the config.php
Therefore You don’t have to think about it anymore, unless You need to debug on the production server.

For sites that I tinker with a lot (like my own), I use this in my production config file config.example.com.php:

return [
    'ready' => function ($kirby) {
        return [
            'debug' => $kirby->user() !== null
        ];
    }
]

This comes with the benefit that I can “turn on debug mode” on my production site by simply logging in (on sites with more than one user we may want to check for user status “admin” or the like in that condition…

For other setups or in the rare situation that I have to debug in production without being logged in, I set an “analogous reminder”, i.e. putting a post-it on my screen or write “Turn of debug mode” on my ToDo list for the day. Very old school, but it works :laughing:

I do like your idea of polling for active debug mode and highlight something in the Panel, though. Sounds like a great fool-proof solution (please share if you come up with a reusable code snippet for that!).

5 Likes

Very clever Sebastian. I think I might have to adopt Your solution! =)

I like the idea of giving debug-mode only to admins that are logged in.

on my site i have to restrict to admins. we have hundreds of ldap-users =)

in case anyone is interested in… that’s my solution in config.php now:

    'ready' => function ($kirby) {
            $loggedinadmin = false;
            if (kirby()->user()) {
                if (kirby()->user()->role()->id() === "admin") {
                    $loggedinadmin = true;
                } 
            }
            return ['debug' => $loggedinadmin];
    }

1 Like

Thanks for sharing and thereby bringing it up in the feed again! This is a beautiful idea @sebastiangreger @demlak <3

Shorter alternative

'ready' => function ($kirby) {
    return ['debug' => kirby()->user() !== null && kirby()->user()->role()->isAdmin()];
}
2 Likes