/**
  * Shows the search popup window with the result
  * @param	string		$string	a search string to search for
  * @param	string		$path		a start path where to search for a string recursively
  */
 public static function showSearchPopup($string, $path = null)
 {
     $path = $path ? $path : dirname(__FILE__);
     static::$_options['minified_html'] = false;
     static::$_options['panel_top'] = '0px';
     static::$_options['panel_right'] = '0px';
     $result = static::_includeCss();
     $result .= '<div style="background: #eee;color: #333;height:100%;">';
     $result .= '<table class="msgTable" id="searchString" border="1" style="width:100%;">';
     $result .= '<tbody><tr><th>#</th><th>file</th><th>line</th>';
     $result .= '<th>string</th><th>occurences</th></tr>';
     $result .= PtcDebug::findString($string, $path);
     $result = str_replace($path, '', $result);
     return $result . '</tbody></table></div>';
 }
 */
session_start();
// start session for persistent debugging and code highlighter popup
require_once '../PtcHm.php';
// require the handyman component
declare (ticks=1);
// declare globally for the code coverage and function calls trace
/* REGISTER THE AUTOLOADER */
PtcHandyMan::register();
// will auto include the ptc-helpers.php file and all other classes
/* START THE DEBUGGER & LOGGER COMPONENT */
$_GET['debug'] = true;
// turn on the debug
//$_GET['debug_off']=true;    		// turn off debug
$options = array('url_key' => 'debug', 'url_pass' => 'true', 'die_on_error' => false, 'exclude_categories' => null);
PtcDebug::load($options);
// initialize the class
/*** PTC DEBUGGER & LOGGER HELPERPS ****************************************************/
/* START CODE COVERAGE ANALYSIS TO CHECK WHICH LINES HAVE BEEN EXECUTED */
ptc_start_coverage();
// PtcDebug::startCoverage( )
/* START FUNCTION CALLS TRACING  */
ptc_start_trace();
// PtcDebug::startTrace( )
/* LOGGING A MESSAGE */
ptc_log('Using phptoolcase helper functions to type less!');
// PtcDebug::bufferLog( )
/* LOGGING SQL QUERIES AND TIMING EXECUTION */
$sql = 'select from where something';
// some sql query, will be used as reference
ptc_log_sql('', $sql);
PtcDebug::addToBuffer($sql, $sql_result);
// attaching the result to the message based on the reference
/* WATCHING A VARIABLE */
declare (ticks=1) {
    $var = 'some test';
    PtcDebug::watch('var');
    // passing the variable without the "$" symbol
    $var = 'some new value';
    // the variable changed
}
/* TIMING A LOOP */
PtcDebug::bufferLog('', 'timing a loop');
// leaving the first parameter empty
for ($i = 0; $i < 100; $i++) {
    @($a[] = $i);
}
PtcDebug::stopTimer('timing a loop');
// using the reference to attach the execution time to the buffer
/* STOP CODE COVERAGE ANALYSIS */
PtcDebug::stopCoverage();
// we could start it again later, if stopCoverage( ) is not used it will be stopped at shutdown
/* STOT TRACING FUNCTION CALLS */
PtcDebug::stopTrace();
// we could start it again later, if stopTrace( ) is not used it will be stopped at shutdown
/* DOWLOAD PHP-CONSOLE FOR CHROME TO SEE MESSAGES IN CONSOLE */
PtcDebug::bufferLog('', '<span style="color:red;">**For Chrome Browser:</span> 
						<a target="_blank" href="https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef">
							Download php-console</a> chrome extension to see debug output in console');
/* CATCHING AN EXCEPTION */
throw new Exception('Uncaught Exception');
//session_destroy();
Beispiel #4
0
 /**
  * Set debug at runtime
  */
 protected static function _setDebug()
 {
     $debug = Module::merge(ptc_path('root') . '/app/config/debug.php');
     if (file_exists(ptc_path('root') . '/app/config/debug_ajax.php')) {
         if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && ('xmlhttprequest' === strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) || 'ajax' === strtolower($_SERVER['HTTP_X_REQUESTED_WITH']))) {
             $debug_ajax = (require_once ptc_path('root') . '/app/config/debug_ajax.php');
             $debug = array_merge($debug, $debug_ajax);
         }
     }
     static::option('debug', $debug);
     require_once ptc_path('root') . '/vendor/phptoolcase/phptoolcase/PtcDebug.php';
     if (!is_null(ptc_array_get(static::$_config, 'debug.replace_error_handler', null))) {
         $die_on_error = ptc_array_get(static::$_config, 'debug.die_on_error') ? true : false;
         Debug::setErrorHandler($die_on_error);
         ptc_array_set(static::$_config, 'debug.replace_error_handler', false, true);
     }
     if (ptc_array_get(static::$_config, 'debug.start')) {
         $exclude = ptc_array_get(static::$_config, 'debug.exclude_categories');
         if (is_string($exclude) && array_key_exists($exclude, static::$_debugLevels)) {
             ptc_array_set(static::$_config, 'debug.exclude_categories', static::$_debugLevels[$exclude], true);
         }
         if (isset($_GET['debug_level'])) {
             ptc_array_set(static::$_config, 'debug.exclude_categories', static::$_debugLevels[$_GET['debug_level']], true);
         }
         Debug::load(static::$_config['debug']);
     }
 }