PHP code example of martino / kirby-debug-toggle

1. Go to this page and download the library: Download martino/kirby-debug-toggle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

martino / kirby-debug-toggle example snippets


return [
    // REQUIRED: Debug mode controlled by flag file
    // Replace any existing 'debug' => true with this closure
    'debug' => (function() {
        $flag = __DIR__ . '/.debug_enabled';
        if (!file_exists($flag)) return false;
        $data = @json_decode(file_get_contents($flag), true);
        if (!$data || empty($data['expires_at'])) return false;
        return time() < $data['expires_at'];
    })(),
    
    // OPTIONAL: Plugin configuration (uses defaults if omitted)
    'Martino.debug-toggle.expiry-hours' => 4,  // Hours until auto-disable (default: 4)
    'Martino.debug-toggle.permission' => 'admin',  // Who can toggle (default: 'admin')
    'Martino.debug-toggle.panel-auto-debug' => true,  // Auto-enable debug for panel (default: true)
];

'Martino.debug-toggle.expiry-hours' => 8,  // 8 hours

   'Martino.debug-toggle.permission' => 'admin',
   

   'Martino.debug-toggle.permission' => 'editor',
   'Martino.debug-toggle.permission' => 'developer',
   

   'Martino.debug-toggle.permission' => function($user) {
       return in_array($user->email(), ['[email protected]', '[email protected]']);
   },
   

'Martino.debug-toggle.panel-auto-debug' => true,  // Always show panel errors to authorized users
'Martino.debug-toggle.panel-auto-debug' => false, // Disable auto-debug (not recommended)