Skip to content

Commit 0c984cd

Browse files
committed
Support Laravel 8.x
1 parent 5201842 commit 0c984cd

File tree

6 files changed

+25
-295
lines changed

6 files changed

+25
-295
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
],
1919
"require": {
2020
"php": "^8.1",
21-
"php-debugbar/php-debugbar": "~2.1.1",
22-
"illuminate/routing": "^9|^10|^11|^12",
23-
"illuminate/session": "^9|^10|^11|^12",
24-
"illuminate/support": "^9|^10|^11|^12",
25-
"symfony/finder": "^6|^7"
21+
"php-debugbar/php-debugbar": "^2.1",
22+
"illuminate/routing": "^8.67|^9|^10|^11|^12",
23+
"illuminate/session": "^8.67|^9|^10|^11|^12",
24+
"illuminate/support": "^8.67|^9|^10|^11|^12",
25+
"symfony/finder": "^5|^6|^7"
2626
},
2727
"require-dev": {
2828
"mockery/mockery": "^1.3.3",

src/DataCollector/FilesCollector.php

Lines changed: 0 additions & 136 deletions
This file was deleted.

src/DataCollector/JobsCollector.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/DataCollector/ModelsCollector.php

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/LaravelDebugbar.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
use Barryvdh\Debugbar\Storage\SocketStorage;
2121
use Barryvdh\Debugbar\Storage\FilesystemStorage;
2222
use Barryvdh\Debugbar\Support\Clockwork\ClockworkCollector;
23-
use Barryvdh\Debugbar\Support\RequestIdGenerator;
2423
use DebugBar\Bridge\MonologCollector;
24+
use DebugBar\Bridge\SwiftMailer\SwiftLogCollector;
25+
use DebugBar\Bridge\SwiftMailer\SwiftMailCollector;
2526
use DebugBar\Bridge\Symfony\SymfonyMailCollector;
2627
use DebugBar\DataCollector\ConfigCollector;
2728
use DebugBar\DataCollector\DataCollectorInterface;
@@ -119,7 +120,6 @@ public function __construct($app = null)
119120
if ($this->is_lumen) {
120121
$this->version = Str::betweenFirst($app->version(), '(', ')');
121122
}
122-
$this->setRequestIdGenerator(new RequestIdGenerator());
123123
}
124124

125125
/**
@@ -473,17 +473,27 @@ function (\Illuminate\Database\Events\ConnectionEstablished $event) {
473473

474474
if ($this->shouldCollect('mail', true) && class_exists('Illuminate\Mail\MailServiceProvider') && $events) {
475475
try {
476-
$mailCollector = new SymfonyMailCollector();
476+
if ($this->checkVersion('9.0')) {
477+
$mailCollector = new SymfonyMailCollector();
478+
$events->listen(function (MessageSent $event) use ($mailCollector) {
479+
$mailCollector->addSymfonyMessage($event->sent->getSymfonySentMessage());
480+
});
481+
} else {
482+
$mailer = $app['mailer']->getSwiftMailer();
483+
$mailCollector = new SwiftMailCollector($mailer);
484+
485+
if ($config->get('debugbar.options.mail.show_body') && $this->hasCollector('messages')) {
486+
$this['messages']->aggregate(new SwiftLogCollector($mailer));
487+
}
488+
}
489+
477490
$this->addCollector($mailCollector);
478-
$events->listen(function (MessageSent $event) use ($mailCollector) {
479-
$mailCollector->addSymfonyMessage($event->sent->getSymfonySentMessage());
480-
});
481491

482492
if ($config->get('debugbar.options.mail.show_body') || $config->get('debugbar.options.mail.full_log')) {
483493
$mailCollector->showMessageBody();
484494
}
485495

486-
if ($this->hasCollector('time') && $config->get('debugbar.options.mail.timeline')) {
496+
if ($this->hasCollector('time') && $config->get('debugbar.options.mail.timeline') && $this->checkVersion('9.0')) {
487497
$transport = $app['mailer']->getSymfonyTransport();
488498
$app['mailer']->setSymfonyTransport(new class ($transport, $this) extends AbstractTransport{
489499
private $originalTransport;
@@ -514,7 +524,9 @@ public function __toString(): string
514524
});
515525
}
516526
} catch (Exception $e) {
517-
$this->addCollectorException('Cannot add SymfonyMailCollector', $e);
527+
$this->addCollectorException(
528+
'Cannot add '.($this->checkVersion('9.0')?'SymfonyMailCollector':'SwiftMailCollector'), $e
529+
);
518530
}
519531
}
520532

@@ -526,9 +538,6 @@ public function __toString(): string
526538
$this->addCollectorException('Cannot add LogsCollector', $e);
527539
}
528540
}
529-
if ($this->shouldCollect('files', false)) {
530-
$this->addCollector(new FilesCollector($app));
531-
}
532541

533542
if ($this->shouldCollect('auth', false)) {
534543
try {

src/Support/RequestIdGenerator.php

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)