Debugger ON/OFF shell script

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
pekelnik
Člen | 462
+
0
-

Download: https://gist.github.com/3452859

Installation: Copy the debug file into your project as bin/debug and make it executable.

Usage: Go to your project directory and run this file to toggle the debugger:

$ bin/debug

Source:

#!/usr/bin/php
<?php

/**
 * Debugger ON/OFF script
 * ======================
 *
 * This script enables or disables the Nette Debugger using regular hidden file.
 * Check your `app/bootstrap.php` to contain this definition of `%debugMode%`:
 *
 * `$parameters['debugMode'] = file_exists(__DIR__ . '/../.debug");`
 */
$debugFile = __DIR__ . '/../.debug';
if (file_exists($debugFile)) {
    echo "Debugger: \033[01;31mOFF\033[00m", PHP_EOL;
    unlink($debugFile);
} else {
    echo "Debugger: \033[01;32mON\033[00m", PHP_EOL;
    touch($debugFile);
}
exit(0);

Note: If you want to measure the request time with disabled debugger add something like this to your www/index.php file:

if (!file_exists(__DIR__ . '/../../.debug')) {
    $time = microtime(TRUE);
    register_shutdown_function(function() use ($time) {
        echo "<div class='container'><pre>Request time: <b> ", round(microtime(true) - $time, 2), " s</b> </pre></div>";
    });
}

Editoval pekelnik (24. 8. 2012 19:21)