Ver Fonte

增加CLI模式

Zhu Jinhui há 7 anos atrás
pai
commit
45012d680a
2 ficheiros alterados com 9 adições e 1 exclusões
  1. 1 1
      Qii/Cache/Redis/Client.php
  2. 8 0
      Qii/Qii.php

+ 1 - 1
Qii/Cache/Redis/Client.php

@@ -370,7 +370,7 @@ class Client
 			$result = $this->redis = @stream_socket_client($remote_socket, $errno, $errstr, $this->timeout !== null ? $this->timeout : 2.5, $flags);
 		} else {
 			if (!$this->redis) {
-				$this->redis = new Redis;
+				$this->redis = new \Redis;
 			}
 			$result = $this->persistent
 				? $this->redis->pconnect($this->host, $this->port, $this->timeout, $this->persistent)

+ 8 - 0
Qii/Qii.php

@@ -170,6 +170,14 @@ if (!function_exists('catch_fatal_error')) {
             $message[] = 'Error file : ' . ltrim($error['file'], Psr4::realpath($_SERVER['DOCUMENT_ROOT']));
             $message[] = 'Error line : ' . $error['line'] . ' on ' . \Qii\Exceptions\Errors::getLineMessage($error['file'], $error['line']);
             $message[] = 'Error description : ' . $error['message'];
+            if(IS_CLI) {
+                return (new \Qii\Response\Cli())->stdout(
+                    str_replace(" "
+                                , " "
+                                , strip_tags(join(PHP_EOL, preg_replace("/[\n|\r\n]/", PHP_EOL, $message)))
+                    )
+                );
+            }
             \Qii\Exceptions\Error::showError($message);
         }
     }