public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response) { // webdebug must be enabled in configuration if (isset($this->config['error']['webdebug']) and $this->config['error']['webdebug'] === 1) { return; } // DEBUG mode must be on if (defined('DEBUG') and DEBUG === true) { return; } /* * ================================================ * Initialize PHP_Debug Web-Debugging Console * ================================================ */ // Additional ini path for PHPDEBUG define('ADD_PHPDEBUG_ROOT', ROOT_LIBRARIES . 'phpdebug'); set_include_path(ADD_PHPDEBUG_APPLICATION_PATH . PATH_SEPARATOR . get_include_path()); // Load Library if (false === class_exists('PHP_Debug', false)) { include ROOT_LIBRARIES . 'phpdebug/PHP/Debug.php'; } // Setup Options for the PHPDebug Object $options = ['render_type' => 'HTML', 'render_mode' => 'div', 'restrict_access' => false, 'allow_url_access' => true, 'url_key' => 'key', 'url_pass' => 'nounou', 'enable_watch' => true, 'replace_errorhandler' => true, 'lang' => 'EN', 'HTML_DIV_view_source_script_name' => APPLICATION_PATH . 'libraries/phpdebug/PHP_Debug_ShowSource.php', 'HTML_DIV_images_path' => WWW_ROOT . 'libraries/phpdebug/images', 'HTML_DIV_css_path' => WWW_ROOT . 'libraries/phpdebug/css', 'HTML_DIV_js_path' => WWW_ROOT . 'libraries/phpdebug/js', 'HTML_DIV_remove_templates_pattern' => true]; // Initialiaze Object $debug = new PHP_Debug($options); // Set Title to Debug Console $debug->add('Koch Framework DEBUG INFO'); /* * Load JS / CSS for PHP Debug Console into the Output Buffer */ $html = '<script type="text/javascript" src="' . $options['HTML_DIV_js_path'] . '/html_div.js"></script>'; $html .= '<link rel="stylesheet" type="text/css"'; $html .= ' media="screen" href="' . $options['HTML_DIV_css_path'] . '/html_div.css" />'; unset($options); // combine the html output $debugbarHTML = $html . $debug->getOutput(); // push output into event object $event = new DebugConsoleResponse_Event($debugbarHTML); // and output the debugging console at the end of the application runtime \Koch\Event\Dispatcher::instantiate()->addEventHandler('onApplicationShutdown', $event); }
<?php // Tests variables ============================================================ // One variable that will be watched by PHP_Debug $watchedVariable = 1; // One session variable to test the debugtype = PHP_DebuLine::TYPE_ENV (4) $_SESSION['Kikoo'] = "One session variable defined"; // Debug Object creation ======================================================= $Dbg = new PHP_Debug($options); // Test restrictAccess() function, only IP in param array will see the debug === //$Dbg->restrictAccess($allowedip); // Test add() function ========================================================= // Standard $renderer = 'HTML_Div'; $intro = 'This is the <b>' . $renderer . '_Renderer</b>, client IP is ' . $_SERVER['REMOTE_ADDR']; $Dbg->add($intro); // Standard, fix end and start time manually $debug_line = $Dbg->add('Manual performance monitoring'); $debug_line->setStartTime(); for ($i = 0; $i < 20000; $i++) { $j = 0; } $debug_line->setEndTime(); // Application settings ======================================================== // Add an application setting $Dbg->addSetting($renderer, 'app_renderer_mode'); // Add a group of application settings $Dbg->addSettings($options, 'app_settings'); // Test dump() function ======================================================== // dump a variable (integer) $foo = 555;
<a href="PHP_Debug_Sources.php">» Show sources</a><br/> </p> <?php // Tests variables ============================================================ // One variable that will be watched by PHP_Debug $watchedVariable = 1; // One session variable to test the debugtype = PHP_DebuLine::TYPE_ENV (4) $_SESSION['Kikoo'] = 'One session variable defined'; // Debug Object creation ======================================================= $Dbg = new PHP_Debug($options); // Test restrictAcess() function, only IP in param array will see the debug ==== //$Dbg->restrictAcess($allowedip); // Test add() function ========================================================= // Standard $Dbg->add("This is the <b>HTML_Table_Render</b>, client IP is " . $_SERVER['REMOTE_ADDR']); // Standard, fix end and start time manually $debug_line = $Dbg->add('Manual performance monitoring'); $debug_line->setStartTime(); for ($i = 0; $i < 20000; $i++) { $j = 0; } $debug_line->setEndTime(); // Test dump() function ======================================================== // dump a variable (integer) $foo = 555; $Dbg->dump($foo, 'Foo'); // dump a variable (double) $foo2 = 37.2; $Dbg->dump($foo2, 'Foo2'); // dump an array
<title>PEAR::PHP_Debug, Hello World !</title> <?php // Options array for Debug object $options = array('HTML_DIV_images_path' => 'images', 'HTML_DIV_css_path' => 'css', 'HTML_DIV_js_path' => 'js'); /** * Include Debug Class */ include_once 'PHP/Debug.php'; // Debug object $Dbg = new PHP_Debug($options); ?> <script type="text/javascript" src="<?php echo $options['HTML_DIV_js_path']; ?> /html_div.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo $options['HTML_DIV_css_path']; ?> /html_div.css" /> </head> <body> <div> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a> </div> <?php echo '<div><h1>PEAR::PHP_Debug, Hello World !</h1></div>'; $Dbg->add('DEBUG INFO'); $Dbg->display(); ?> </body> </html>