Skip to content

Commit ff81dcf

Browse files
committed
[Serializer] Add serializer profiler
1 parent a22f26e commit ff81dcf

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ class FrameworkExtension extends Extension
237237
private bool $mailerConfigEnabled = false;
238238
private bool $httpClientConfigEnabled = false;
239239
private bool $notifierConfigEnabled = false;
240+
private bool $serializerConfigEnabled = false;
240241
private bool $propertyAccessConfigEnabled = false;
241242
private static bool $lockConfigEnabled = false;
242243

@@ -386,7 +387,7 @@ public function load(array $configs, ContainerBuilder $container)
386387

387388
$container->getDefinition('exception_listener')->replaceArgument(3, $config['exceptions']);
388389

389-
if ($this->isConfigEnabled($container, $config['serializer'])) {
390+
if ($this->serializerConfigEnabled = $this->isConfigEnabled($container, $config['serializer'])) {
390391
if (!class_exists(\Symfony\Component\Serializer\Serializer::class)) {
391392
throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
392393
}
@@ -516,7 +517,7 @@ public function load(array $configs, ContainerBuilder $container)
516517
$this->registerNotifierConfiguration($config['notifier'], $container, $loader);
517518
}
518519

519-
// profiler depends on form, validation, translation, messenger, mailer, http-client, notifier being registered
520+
// profiler depends on form, validation, translation, messenger, mailer, http-client, notifier, serializer being registered
520521
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);
521522

522523
$this->addAnnotatedClassesToCompile([
@@ -798,6 +799,10 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
798799
$loader->load('notifier_debug.php');
799800
}
800801

802+
if ($this->serializerConfigEnabled) {
803+
$loader->load('serializer_debug.php');
804+
}
805+
801806
$container->setParameter('profiler_listener.only_exceptions', $config['only_exceptions']);
802807
$container->setParameter('profiler_listener.only_main_requests', $config['only_main_requests']);
803808

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
15+
use Symfony\Component\Serializer\Debug\TraceableSerializer;
16+
17+
return static function (ContainerConfigurator $container) {
18+
$container->services()
19+
->set('debug.serializer', TraceableSerializer::class)
20+
->decorate('serializer', null, 255)
21+
->args([
22+
service('debug.serializer.inner'),
23+
service('serializer.data_collector'),
24+
])
25+
26+
->set('serializer.data_collector', SerializerDataCollector::class)
27+
->tag('data_collector', [
28+
'template' => '@WebProfiler/Collector/serializer.html.twig',
29+
'id' => 'serializer',
30+
])
31+
;
32+
};

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"symfony/mime": "<5.4",
8686
"symfony/property-info": "<5.4",
8787
"symfony/property-access": "<5.4",
88-
"symfony/serializer": "<5.4",
88+
"symfony/serializer": "<6.1",
8989
"symfony/security-csrf": "<5.4",
9090
"symfony/security-core": "<5.4",
9191
"symfony/stopwatch": "<5.4",

0 commit comments

Comments
 (0)