<?php if (isset($_GET['debug'])) { xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); // System Start Time define('START_TIME', microtime(true)); // System Start Memory define('START_MEMORY_USAGE', memory_get_usage()); } error_reporting(E_ALL); ini_set('display_errors', 'on'); date_default_timezone_set('Asia/Shanghai'); require '../Cola/Cola.php'; $cola = Cola::getInstance(); //$benchmark = new Cola_Com_Benchmark(); $cola->boot()->dispatch(); //echo "<br />cost:", $benchmark->cost(), 's'; if (!isset($_GET['debug'])) { die; } $xhprof_data = xhprof_disable(); echo "Page rendered in <b>" . round(microtime(true) - START_TIME, 5) * 1000 . " ms</b>, taking <b>" . round((memory_get_usage() - START_MEMORY_USAGE) / 1024, 2) . " KB</b>"; $f = get_included_files(); echo ", include files: " . count($f); $XHPROF_ROOT = realpath(dirname(__FILE__) . '/../..'); include_once $XHPROF_ROOT . "/xhprof/xhprof_lib/utils/xhprof_lib.php"; include_once $XHPROF_ROOT . "/xhprof/xhprof_lib/utils/xhprof_runs.php"; // save raw data for this profiler run using default // implementation of iXHProfRuns. $xhprof_runs = new XHProfRuns_Default(); // save the run under a namespace "xhprof_foo"
/** * Dynamic get vars * * @param string $key */ public function __get($key) { switch ($key) { case 'db': $this->db = $this->db(); return $this->db; case 'cache': $this->cache = $this->cache(); return $this->cache; case 'config': $this->config = Cola::getInstance()->config; return $this->config; default: throw new Cola_Exception('Undefined property: ' . get_class($this) . '::' . $key); } }
/** * Dynamic get vars * * @param string $key */ public function __get($key) { switch ($key) { case 'view': $this->view(); return $this->view; case 'request': $this->request = new Cola_Request(); return $this->request; case 'response': $this->response = new Cola_Response(); return $this->response; case 'config': $this->config = Cola::getInstance()->config; return $this->config; default: throw new Cola_Exception('Undefined property: ' . get_class($this) . '::' . $key); } }
/** * Get default template file path * * @return string */ protected function defaultTemplate() { $cola = Cola::getInstance(); $dispatchInfo = $cola->getDispatchInfo(); $tpl = str_replace('_', DIRECTORY_SEPARATOR, substr($dispatchInfo['controller'], 0, -10)) . DIRECTORY_SEPARATOR . substr($dispatchInfo['action'], 0, -6) . $this->_tplExt; return $tpl; }
/** * Dynamic get vars * * @param string $key */ public function __get($key) { switch ($key) { case 'config': $this->config = Cola::getInstance()->config; return $this->config; default: return null; } }