Skip to content

Commit c765a52

Browse files
authored
Use tooltip for Laravel collector (barryvdh#1724)
* Use tooltip for Laravel collector * Tweak typehint * Simplify
1 parent f3510d8 commit c765a52

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

config/debugbar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
*/
161161

162162
'collectors' => [
163-
'phpinfo' => true, // Php version
163+
'phpinfo' => false, // Php version
164164
'messages' => true, // Messages
165165
'time' => true, // Time Datalogger
166166
'memory' => true, // Memory usage
@@ -174,7 +174,7 @@
174174
'session' => true, // Display session data
175175
'symfony_request' => true, // Only one can be enabled..
176176
'mail' => true, // Catch mail messages
177-
'laravel' => false, // Laravel version and environment
177+
'laravel' => true, // Laravel version and environment
178178
'events' => false, // All events fired
179179
'default_request' => false, // Regular or special Symfony request logger
180180
'logs' => false, // Add the latest log messages

src/DataCollector/LaravelCollector.php

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,42 @@
44

55
use DebugBar\DataCollector\DataCollector;
66
use DebugBar\DataCollector\Renderable;
7+
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
78
use Illuminate\Foundation\Application;
9+
use Illuminate\Support\Str;
810

911
class LaravelCollector extends DataCollector implements Renderable
1012
{
11-
/** @var \Illuminate\Foundation\Application $app */
12-
protected $app;
13-
1413
/**
1514
* @param Application $app
1615
*/
17-
public function __construct(?Application $app = null)
16+
public function __construct(protected ApplicationContract $laravel)
1817
{
19-
$this->app = $app;
2018
}
2119

2220
/**
2321
* {@inheritDoc}
2422
*/
2523
public function collect()
2624
{
27-
// Fallback if not injected
28-
$app = $this->app ?: app();
25+
return [
26+
"version" => Str::of($this->laravel->version())->explode('.')->first(),
27+
];
28+
}
2929

30+
/**
31+
* {@inheritDoc}
32+
*/
33+
public function gatherData()
34+
{
3035
return [
31-
"version" => $app::VERSION,
32-
"environment" => $app->environment(),
33-
"locale" => $app->getLocale(),
36+
'Laravel Version' => $this->laravel->version(),
37+
'PHP Version' => phpversion(),
38+
'Environment' => $this->laravel->environment(),
39+
'Debug Mode' => config('app.debug') ? 'Enabled' : 'Disabled',
40+
'URL' => Str::of(config('app.url'))->replace(['http://', 'https://'], ''),
41+
'Timezone' => config('app.timezone'),
42+
'Locale' => config('app.locale'),
3443
];
3544
}
3645

@@ -50,22 +59,10 @@ public function getWidgets()
5059
return [
5160
"version" => [
5261
"icon" => "laravel phpdebugbar-fab",
53-
"tooltip" => "Laravel Version",
62+
"tooltip" => $this->gatherData(),
5463
"map" => "laravel.version",
5564
"default" => ""
5665
],
57-
"environment" => [
58-
"icon" => "desktop",
59-
"tooltip" => "Environment",
60-
"map" => "laravel.environment",
61-
"default" => ""
62-
],
63-
"locale" => [
64-
"icon" => "flag",
65-
"tooltip" => "Current locale",
66-
"map" => "laravel.locale",
67-
"default" => "",
68-
],
6966
];
7067
}
7168
}

0 commit comments

Comments
 (0)