/** * @param Application $app */ public function __construct($app) { parent::__construct($app); return; // for debug only if (JFactory::getApplication()->isSite() && self::$_jbdump === null) { if (class_exists('jbdump')) { // jbdump plugin self::$_jbdump = JBDump::i($this->_jbdumpParams); } } }
/** * JBDump init */ function onAfterInitialise() { $logPath = $this->params->get('logPath', JPATH_ROOT . DS . 'logs'); if (empty($logPath)) { $logPath = JPATH_ROOT . DS . 'logs'; } $logFile = $this->params->get('logFile', false); if (empty($logFile)) { $logFile = false; } // init and configuration JBDump library $params = array('root' => JPATH_SITE, 'logPath' => $logPath, 'logFile' => $logFile, 'serialize' => $this->params->get('serialize', 'print_r'), 'logFormat' => "{DATETIME}\t{CLIENT_IP}\t\t{FILE}\t\t{NAME}\t\t{TEXT}", 'autoProfile' => (int) $this->params->get('autoProfile', true), 'profileToFile' => (int) $this->params->get('profileToFile', false), 'sort' => array('array' => (int) $this->params->get('sort_array', false), 'object' => (int) $this->params->get('sort_object', true), 'methods' => (int) $this->params->get('sort_methods', true)), 'handler' => array('error' => (int) $this->params->get('handler_error', true), 'exception' => (int) $this->params->get('handler_exception', true), 'context' => (int) $this->params->get('handler_context', false)), 'ip' => $this->params->get('ip', false), 'requestParam' => $this->params->get('requestParam', false), 'requestValue' => $this->params->get('requestValue', false), 'lite_mode' => (int) $this->params->get('lite_mode', false), 'stringLength' => $this->params->get('stringLength', 50), 'maxDepth' => $this->params->get('maxDepth', 3), 'showMethods' => (int) $this->params->get('showMethods', true), 'allToLog' => (int) $this->params->get('allToLog', false), 'showArgs' => (int) $this->params->get('showMethods', false)); // init jbdump JBDump::i('jbdump', $params); }
/** * @param Application $app */ public function __construct($app) { parent::__construct($app); return; // for debug only if (self::$_jbdump === null) { // Joomla standart profiler if (JDEBUG) { self::$_jbdump = JProfiler::getInstance('Application'); } // jbdump plugin if (class_exists('jbdump')) { self::$_jbdump = JBDump::i($this->_jbdumpParams); } } }
/** * Alias for JBDump::i()->dump($var) with additions params * @param mixed $var Variable * @param string $name Variable name * @param bool $isDie Die after dump * @return JBDump */ function jbdump($var = 'JBDump::variable is no set', $isDie = true, $name = '...') { $_this = JBDump::i(); if ($var != 'JBDump::variable is no set') { if ($_this->isDebug()) { $_this->dump($var, $name); $isDie && die('JBDump_auto_die'); } } return $_this; }
<h3>Code</h3><?php JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source'); ?> <h3>Result</h3><?php JBDump::memory(); JBDump::mark('start loop'); $bigArray = array(0 => 0); for ($i = 1; $i < 10000; $i++) { $bigArray[$i] = $i + @$bigArray[$i - 1]; } JBDump::mark('finish loop'); unset($bigArray); JBDump::mark('unset $bigArray'); JBDump::mark('start loop #2'); for ($i = 0; $i < 1000000; $i++) { } JBDump::mark('finish loop #2'); JBDump::mark('start loop #3'); $j = 0; for ($i = 0; $i < 1000000; $i++) { $j++; } JBDump::mark('finish loop #3'); echo "JBDump::microtime();"; JBDump::microtime(); echo "JBDump::memory();"; JBDump::memory(); echo "JBDump::microtime();"; JBDump::microtime(); JBDump::i()->mark('other functions');
* @copyright Copyright (c) 2009-2011 Joomla-book.ru * @license GNU General Public License version 2 or later; see LICENSE */ include './included_file.php'; JBDump::showErrors(); ?> <h3>Code</h3><?php JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source'); ?> <h3>Result</h3><?php $logger = JBDump::i(); echo 'Disable for demo'; JBDump::off(); // only for test JBDump::log($var['null'], 'null'); JBDump::log($var['bool'], 'Boolean'); JBDump::log($var['integer'], 'Integer'); JBDump::log($var['float'], 'Float'); JBDump::log($var['string'], 'String'); JBDump::log($var['longString'], 'longString'); JBDump::log($var['stdClass'], 'stdClass'); JBDump::log($var['simpleObject'], 'simpleObject'); JBDump::log($var['var'], 'complex var'); //// other methods JBDump::i()->log('Hello world!'); if (function_exists('l')) { l('short log function'); } // set params $logger->setParams(array('file' => 'newLogName'), 'log')->log($var['string'], 'message_name'); $logger->setParams(array('file' => 'newLogFormat', 'format' => "{DATETIME}\t{CLIENT_IP} --------- {VAR1} // {VAR2} // {VAR3}", 'serialize' => 'format'), 'log')->log(array('var1' => '1', 'Var2' => '2', 'vAR3' => '3', 'VAR4' => '4'));
<h3>Code</h3><?php JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source'); ?> <h3>Result</h3><?php ?> <h3>Classes</h3><?php echo "JBDump::classInfo('simpleInterface');"; JBDump::classInfo('simpleInterface'); echo "JBDump::classInfo('simpleRootObject');"; JBDump::classInfo('simpleRootObject'); echo "JBDump::classInfo('simpleParentObject');"; JBDump::classInfo('simpleParentObject'); echo "JBDump::classInfo(new simpleObject());"; JBDump::classInfo(new simpleObject()); echo "JBDump::classInfo(JBDump::i());"; JBDump::classInfo(JBDump::i()); echo "JBDump::classInfo('reflection');"; JBDump::classInfo('reflection'); echo "JBDump::classInfo('unknowClass_123');"; JBDump::classInfo('unknowClass_123'); ?> <h3>Functions</h3><?php echo "JBDump::funcInfo('simpleFunction');"; JBDump::funcInfo('simpleFunction'); echo 'JBDump::funcInfo($simpleClosureFunction);'; JBDump::funcInfo($simpleClosureFunction); echo "JBDump::funcInfo('is_array');"; JBDump::funcInfo('is_array'); echo "JBDump::funcInfo('mysql_query');"; JBDump::funcInfo('mysql_query'); echo "JBDump::funcInfo('call_user_method_array');";
<?php /** * @package JBDump test * @version 1.2.0 * @author admin@joomla-book.ru * @link http://joomla-book.ru/ * @copyright Copyright (c) 2009-2011 Joomla-book.ru * @license GNU General Public License version 2 or later; see LICENSE */ include './included_file.php'; JBDump::showErrors(); ?> <h3>Code</h3><?php JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source'); echo 'Disabled for demo'; JBDump::off(); JBDump::mail('Test message'); JBDump::mail('Test message', null, '*****@*****.**'); JBDump::mail('Test message', 'Test subject text', null); JBDump::mail('Test message', 'Test subject text', '*****@*****.**'); JBDump::i()->mail(array('test' => 'test2', 'test4' => 'test3'));
/** * Useful console dump * @param mixed $var * @param bool $isDie * @param string $label * @throws Exception * * @SuppressWarnings(PHPMD.ExitExpression) * @SuppressWarnings(PHPMD.NPathComplexity) */ function dump($var, $isDie = true, $label = '') { if (!class_exists('\\JBDump')) { throw new Exception('jbzoo/jbdump required for dump() function'); } if (!class_exists('\\Symfony\\Component\\VarDumper\\VarDumper')) { throw new Exception('symfony/var-dumper required for dump() function'); } $isCliMode = defined('STDOUT'); // get trace mesage $trace = debug_backtrace(false); $dirname = pathinfo(dirname($trace[0]['file']), PATHINFO_BASENAME); $filename = pathinfo($trace[0]['file'], PATHINFO_BASENAME); $line = $trace[0]['line']; $callplace = "({$dirname}/{$filename}:{$line})"; // output backtrace information $message = $label ? '--- "' . $label . '" ---' : str_repeat('-', 20); $message = PHP_EOL . $message . ' ' . $callplace; if ($isCliMode) { fwrite(STDOUT, $message . PHP_EOL); $isSimpleVar = is_string($var) || is_numeric($var) || is_bool($var) || null === $var; if ($isSimpleVar) { ob_start(); var_dump($var); $dump = ob_get_contents(); ob_end_clean(); fwrite(STDOUT, $dump); } else { putenv("ANSICON=on"); // Add colored output VarDumper::dump($var); } } elseif (class_exists('\\JBDump')) { $jbdump = \JBDump::i(array('log' => array('path' => PROJECT_ROOT . '/logs'), 'profiler' => array('render' => 4, 'auto' => 1, 'showStart' => 0, 'showEnd' => 0, 'showOnAjax' => 1), 'dump' => array('die' => 0, 'maxDepth' => 5, 'expandLevel' => 3))); if ($jbdump->isDebug()) { $jbdump->dump($var, $label, array('trace' => debug_backtrace())); } } else { echo $message . '<br/>'; var_dump($var); } if ($isDie) { if ($isCliMode) { fwrite(STDOUT, 'Dump die!' . PHP_EOL); exit(255); } else { die('Dump die!' . PHP_EOL); } } }