Ejemplo n.º 1
0
 /**
  * Get Page Trace
  *
  * @return array
  */
 protected function getTrace()
 {
     $files = get_included_files();
     $config = Config::getSoul()->getArray();
     $server = $_SERVER;
     $cookie = $_COOKIE;
     $info = array();
     foreach ($files as $key => $file) {
         $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )';
     }
     $hook = Hook::getTags();
     foreach ($hook as $key => $value) {
         $hook[$key] = ' ( ' . $value . ' μs )';
     }
     $error = Handle::$errors;
     $database = Database::getSoul(Config::getSoul()->SELECTED_DB_KEY);
     $sql = $database == null ? array() : $database->queries;
     $base = array('Request Info' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['PHP_SELF'], 'Run Time' => Hook::listen('\\Kotori\\App') . 'μs', 'TPR' => Hook::listen('\\Kotori\\App') != 0 ? pow(10, 6) / Hook::listen('\\Kotori\\App') . ' req/s' : '+inf', 'Memory Uses' => number_format((memory_get_usage() - START_MEMORY) / 1024, 2) . ' kb', 'SQL Queries' => count($sql) . ' queries ', 'File Loaded' => count(get_included_files()), 'Session Info' => 'SESSION_ID=' . session_id());
     $support = array('<a target="_blank" href="https://github.com/kokororin/Kotori.php">GitHub</a>', '<a target="_blank" href="https://kotori.love/archives/kotori-php-framework.html">Blog</a>');
     $trace = array();
     foreach ($this->traceTabs as $name => $title) {
         switch (strtoupper($name)) {
             case 'BASE':
                 $trace[$title] = $base;
                 break;
             case 'CONFIG':
                 $trace[$title] = $config;
                 break;
             case 'SERVER':
                 $trace[$title] = $server;
                 break;
             case 'COOKIE':
                 $trace[$title] = $cookie;
                 break;
             case 'FILE':
                 $trace[$title] = $info;
                 break;
             case 'FLOW':
                 $trace[$title] = $hook;
                 break;
             case 'ERROR':
                 $trace[$title] = $error;
                 break;
             case 'SQL':
                 $trace[$title] = $sql;
                 break;
             case 'SUPPORT':
                 $trace[$title] = $support;
                 break;
         }
     }
     return $trace;
 }
Ejemplo n.º 2
0
 /**
  * DB selector
  *
  * @param  string $key database key in config
  * @return Database
  */
 public function db($key = null)
 {
     return Database::getSoul($key);
 }