Skip to content

Commit

Permalink
mapping base_path
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed Nov 4, 2015
1 parent 2b208eb commit b4e4314
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions config/tracy.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

return [
'base_path' => null,
'strictMode' => true,
'maxDepth' => 4,
'maxLen' => 1000,
Expand Down
21 changes: 21 additions & 0 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<uri>'.strtr(Debugger::$editor, [
'%file' => '(?P<file>.+)',
'%line' => '(?P<line>\d+)',
'?' => '\?',
'&' => '(&|&amp;)',
]).')#';

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;
}

Expand Down
21 changes: 1 addition & 20 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Support\ServiceProvider as baseServiceProvider;
use Tracy\Debugger;
use Tracy\Dumper;

class ServiceProvider extends baseServiceProvider
{
Expand All @@ -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');
Expand Down

0 comments on commit b4e4314

Please sign in to comment.