CrossPHP
  • Namespace
  • Class
  • Download

Namespaces

  • Cross
    • Auth
    • Cache
      • Driver
      • Request
    • Core
    • DB
      • Connecter
      • Drivers
      • SQLAssembler
    • Exception
    • Http
    • I
    • Lib
      • Document
    • Module
    • MVC
    • Runtime
  • None

Classes

  • Cross\Auth\CookieAuth
  • Cross\Auth\SessionAuth
  • Cross\Cache\Driver\FileCacheDriver
  • Cross\Cache\Driver\MemcacheDriver
  • Cross\Cache\Driver\RedisDriver
  • Cross\Cache\Request\FileCache
  • Cross\Cache\Request\Memcache
  • Cross\Cache\Request\RedisCache
  • Cross\Cache\RequestCache
  • Cross\Core\Annotate
  • Cross\Core\Application
  • Cross\Core\ArrayMap
  • Cross\Core\Config
  • Cross\Core\CrossArray
  • Cross\Core\Delegate
  • Cross\Core\FrameBase
  • Cross\Core\Helper
  • Cross\Core\HttpAuth
  • Cross\Core\Loader
  • Cross\Core\Rest
  • Cross\Core\Router
  • Cross\DB\Connecter\BaseConnecter
  • Cross\DB\Connecter\MySQLConnecter
  • Cross\DB\Connecter\PgSQLConnecter
  • Cross\DB\Connecter\SQLiteConnecter
  • Cross\DB\DBFactory
  • Cross\DB\Drivers\CouchDriver
  • Cross\DB\Drivers\MongoDriver
  • Cross\DB\Drivers\PDOSqlDriver
  • Cross\DB\SQLAssembler\MySQLAssembler
  • Cross\DB\SQLAssembler\PgSQLAssembler
  • Cross\DB\SQLAssembler\SQLAssembler
  • Cross\DB\SQLAssembler\SQLiteAssembler
  • Cross\Http\Request
  • Cross\Http\Response
  • Cross\Lib\Array2XML
  • Cross\Lib\Document\CallTree
  • Cross\Lib\Document\CallTreeToHTML
  • Cross\Lib\Document\HTML
  • Cross\Lib\StringToPHPStream
  • Cross\Module\SQLModule
  • Cross\MVC\Controller
  • Cross\MVC\Module
  • Cross\MVC\View
  • Cross\Runtime\ClosureContainer

Interfaces

  • Cross\I\CacheInterface
  • Cross\I\HttpAuthInterface
  • Cross\I\PDOConnecter
  • Cross\I\RequestCacheInterface
  • Cross\I\RouterInterface
  • Cross\I\SqlInterface

Exceptions

  • Cross\Exception\CacheException
  • Cross\Exception\CoreException
  • Cross\Exception\CrossException
  • Cross\Exception\FrontException

Functions

  • ascLogo
  • line
  • tBody
  • th
  • tHead
  1 <?php
  2 /**
  3  * cli模式下输出异常信息的模板
  4  *
  5  * 根据message中的trace_table 输出一个trace信息的文字表格
  6  * 内容为message['trace']
  7  */
  8 if (!empty($message)) {
  9 
 10     $trace = &$message['trace'];
 11     $table = &$message['trace_table'];
 12     $previous_trace = &$message['previous_trace'];
 13 
 14     /**
 15      * 输出ASC logo
 16      */
 17     if (!function_exists('ascLogo')) {
 18         function ascLogo($txtTableInfo)
 19         {
 20             $line_width = array_sum($txtTableInfo) + count($txtTableInfo) + 1;
 21             $asc_logo_data = <<<ASC_LOGO
 22                                    __         v%s
 23   ______________  ______________  / /_  ____
 24  / ___/ ___/ __ \/ ___/ ___/ __ \/ __ \/ __ \
 25 / /__/ /  / /_/ (__  )__  ) /_/ / / / / /_/ /
 26 \___/_/   \____/____/____/ .___/_/ /_/ .___/
 27                         /_/         /_/
 28 ASC_LOGO;
 29 
 30             $logo_lines = explode("\n", sprintf($asc_logo_data, \Cross\Core\Delegate::getVersion()));
 31             $offset = 6;
 32             $max_width = 0;
 33             foreach ($logo_lines as $line) {
 34                 $length = strlen($line);
 35                 if ($length > $max_width) {
 36                     $max_width = $length;
 37                 }
 38             }
 39 
 40             $half_width = floor($line_width / 2 - ($max_width - $offset) / 2);
 41             foreach ($logo_lines as $line) {
 42                 for ($i = 0; $i <= $line_width; $i++) {
 43                     if ($i == $half_width) {
 44                         echo $line;
 45                     } elseif ($i < $half_width) {
 46                         echo ' ';
 47                     }
 48                 }
 49                 echo PHP_EOL;
 50             }
 51             echo PHP_EOL;
 52         }
 53     }
 54 
 55     /**
 56      * 输出带标题的横线
 57      *
 58      * @param $txtTableInfo
 59      * @param string $text
 60      * @param string $pad_string
 61      */
 62     if (!function_exists('line')) {
 63         function line($txtTableInfo, $text = '', $pad_string = '=')
 64         {
 65             $text_length = 0;
 66             if (!empty($text)) {
 67                 $text_length = strlen($text);
 68             }
 69 
 70             $line_width = array_sum($txtTableInfo) + count($txtTableInfo) + 1;
 71             $s = floor($line_width / 2 - $text_length / 2);
 72             for ($i = 0; $i < $line_width; $i++) {
 73                 if ($i == $s) {
 74                     echo $text;
 75                     $i += $text_length;
 76                 }
 77                 echo $pad_string;
 78             }
 79             echo PHP_EOL;
 80         }
 81     }
 82 
 83     /**
 84      * 输出表格边框
 85      *
 86      * @param $txtTableInfo
 87      */
 88     if (!function_exists('th')) {
 89         function th($txtTableInfo)
 90         {
 91             echo '+';
 92             foreach ($txtTableInfo as $type_name => $line_width) {
 93                 for ($i = 0; $i < $line_width; $i++) {
 94                     echo '-';
 95                 }
 96                 echo '+';
 97             }
 98             echo PHP_EOL;
 99         }
100     }
101 
102     /**
103      * 输出txt表格头(标题居中)
104      *
105      * @param $txtTableInfo
106      */
107     if (!function_exists('tHead')) {
108         function tHead($txtTableInfo)
109         {
110             echo '|';
111             foreach ($txtTableInfo as $type_name => $line_width) {
112                 $name_width = strlen($type_name);
113                 $name_offset = floor($line_width / 2 - $name_width / 2) + 1;
114 
115                 $i = 0;
116                 while ($i++ < $line_width) {
117                     if ($i == $name_offset) {
118                         echo ucfirst($type_name);
119                         $i += $name_width - 1;
120                     } else {
121                         echo ' ';
122                     }
123                 }
124                 echo '|';
125             }
126             echo PHP_EOL;
127         }
128     }
129 
130     /**
131      * 输出表格的内容
132      *
133      * @param $data
134      * @param $txtTableInfo
135      */
136     if (!function_exists('tBody')) {
137         function tBody($data, $txtTableInfo)
138         {
139             echo '|';
140             foreach ($txtTableInfo as $type => $line_width) {
141                 $content_length = strlen($data[$type]);
142                 $i = 0;
143                 while ($i++ < $line_width) {
144                     if ($i == 2) {
145                         echo $data[$type];
146                         $i += $content_length - 1;
147                     } else {
148                         echo ' ';
149                     }
150                 }
151                 echo '|';
152             }
153             echo PHP_EOL;
154         }
155     }
156 
157     echo PHP_EOL;
158     ascLogo($table);
159     line($table, '--  Exception Start  --');
160     printf("\n Message: %s \n File: %s   Line: %s \n\n", $message['message'], $message['file'], $message['line']);
161 
162     th($table);
163     thead($table);
164     th($table);
165 
166     if (!empty($trace)) {
167         foreach ($trace as $t) {
168             tBody($t, $table);
169         }
170         th($table);
171     }
172 
173     if (!empty($previous_trace)) {
174         line($table, 'Previous Trace', ' ');
175         th($table);
176         foreach ($previous_trace as $t) {
177             tBody($t, $table);
178         }
179         th($table);
180     }
181 
182     echo PHP_EOL;
183     line($table, sprintf("--  Exception END  %s  --", date('Y-m-d H:i:s', time())));
184 }
185 
186 
187 
CrossPHP API documentation generated by ApiGen