diff --git a/convention.php b/convention.php index 8ea38c69..3ad29bb5 100644 --- a/convention.php +++ b/convention.php @@ -150,7 +150,8 @@ return [ // | Trace设置 // +---------------------------------------------------------------------- 'trace' => [ - 'type' => 'Html' //支持Html,Console 设为false则不显示 + //支持Html,Console 设为false则不显示 + 'type' => false, ], // +---------------------------------------------------------------------- diff --git a/library/think/debug/trace/Console.php b/library/think/debug/trace/Console.php index 596486b7..0cbe12e6 100644 --- a/library/think/debug/trace/Console.php +++ b/library/think/debug/trace/Console.php @@ -46,9 +46,15 @@ class Console $reqs = number_format(1 / $runtime, 2); $mem = number_format((memory_get_usage() - START_MEM) / 1024, 2); + if (isset($_SERVER['HTTP_HOST'])) { + $uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + } else { + $uri = "cmd:" . implode(' ', $_SERVER['argv']); + } + // 页面Trace信息 $base = [ - '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], + '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri, '运行时间' => "{$runtime}s [ 吞吐率:{$reqs}req/s ] 内存消耗:{$mem}kb 文件加载:" . count(get_included_files()), '查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ', '缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes', diff --git a/library/think/debug/trace/Html.php b/library/think/debug/trace/Html.php index f5b8e724..8e002567 100644 --- a/library/think/debug/trace/Html.php +++ b/library/think/debug/trace/Html.php @@ -48,8 +48,13 @@ class Html $mem = number_format((memory_get_usage() - START_MEM) / 1024, 2); // 页面Trace信息 + if (isset($_SERVER['HTTP_HOST'])) { + $uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + } else { + $uri = "cmd:" . implode(' ', $_SERVER['argv']); + } $base = [ - '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], + '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri, '运行时间' => "{$runtime}s [ 吞吐率:{$reqs}req/s ] 内存消耗:{$mem}kb 文件加载:" . count(get_included_files()), '查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ', '缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes', diff --git a/tests/thinkphp/library/think/appTest.php b/tests/thinkphp/library/think/appTest.php index f019cb7b..df126929 100644 --- a/tests/thinkphp/library/think/appTest.php +++ b/tests/thinkphp/library/think/appTest.php @@ -54,10 +54,10 @@ class appTest extends \PHPUnit_Framework_TestCase $this->expectOutputString($expectOutputString); $rc = new ReflectionClass('\think\Loader'); - $ns = $rc->getProperty('namespace'); + $ns = $rc->getProperty('prefixDirsPsr4'); $ns->setAccessible(true); $namespace = $ns->getValue(); - $this->assertEquals(TEST_PATH, $namespace['tests']); + $this->assertEquals([TEST_PATH], $namespace['tests\\']); $this->assertEquals(true, function_exists('lang')); $this->assertEquals(true, function_exists('config')); diff --git a/tests/thinkphp/library/think/routeTest.php b/tests/thinkphp/library/think/routeTest.php index 751486f0..d2da4b66 100644 --- a/tests/thinkphp/library/think/routeTest.php +++ b/tests/thinkphp/library/think/routeTest.php @@ -84,7 +84,7 @@ class routeTest extends \PHPUnit_Framework_TestCase Route::map('hello', 'index/hello'); $this->assertEquals('index/hello', Route::map('hello')); $result = Route::check($request, 'hello'); - $this->assertEquals(['index', 'hello', null], $result['module']); + $this->assertEquals([null, 'index', 'hello'], $result['module']); } public function testMixVar()