From b4e431445afbfd151391ad4ba4ec2d766866907a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Nov 2015 12:44:53 +0800 Subject: [PATCH] mapping base_path --- config/tracy.php | 1 + src/Helper.php | 21 +++++++++++++++++++++ src/ServiceProvider.php | 21 +-------------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/config/tracy.php b/config/tracy.php index 9a6075a..1c67450 100644 --- a/config/tracy.php +++ b/config/tracy.php @@ -1,6 +1,7 @@ null, 'strictMode' => true, 'maxDepth' => 4, 'maxLen' => 1000, diff --git a/src/Helper.php b/src/Helper.php index cce4cdd..5b7008d 100644 --- a/src/Helper.php +++ b/src/Helper.php @@ -25,6 +25,27 @@ public static function getBlueScreen($e) ->render($e); $content = ob_get_clean(); + $basePath = config('tracy.base_path'); + + if (empty($basePath) === false) { + $compiled = '#(?P'.strtr(Debugger::$editor, [ + '%file' => '(?P.+)', + '%line' => '(?P\d+)', + '?' => '\?', + '&' => '(&|&)', + ]).')#'; + + if (preg_match_all($compiled, $content, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + $uri = $match['uri']; + $file = str_replace(base_path(), $basePath, rawurldecode($match['file'])); + $line = $match['line']; + $editor = strtr(Debugger::$editor, ['%file' => rawurlencode($file), '%line' => $line ? (int) $line : '']); + $content = str_replace($uri, $editor, $content); + } + } + } + return $content; } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index ef38ea1..2f7fbc8 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -4,7 +4,6 @@ use Illuminate\Support\ServiceProvider as baseServiceProvider; use Tracy\Debugger; -use Tracy\Dumper; class ServiceProvider extends baseServiceProvider { @@ -30,25 +29,7 @@ public function register() { if (config('app.debug') === true and $this->app->runningInConsole() === false) { $this->mergeConfigFrom(__DIR__.'/../config/tracy.php', 'tracy'); - $config = array_merge([ - 'strictMode' => true, - 'maxDepth' => 4, - 'maxLen' => 1000, - 'showLocation' => true, - 'editor' => 'subl://open?url=file://%file&line=%line', - 'panels' => [ - 'Recca0120\LaravelTracy\Panels\RoutingPanel', - 'Recca0120\LaravelTracy\Panels\DatabasePanel', - 'Recca0120\LaravelTracy\Panels\SessionPanel', - 'Recca0120\LaravelTracy\Panels\RequestPanel', - 'Recca0120\LaravelTracy\Panels\EventPanel', - 'Recca0120\LaravelTracy\Panels\UserPanel', - ], - 'dumpOption' => [ - Dumper::COLLAPSE => false, - 'live' => true, - ], - ], config('tracy')); + $config = config('tracy'); Debugger::$time = array_get($_SERVER, 'REQUEST_TIME_FLOAT', microtime(true)); Debugger::$maxDepth = array_get($config, 'maxDepth');