Repository: symfony/symfony
File: src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.php (PHP)

Code before:
        ->set('data_collector.logger', LoggerDataCollector::class)
            ->args([
                service('logger')->ignoreOnInvalid(),
                \sprintf('%s/%s', param('kernel.build_dir'), param('kernel.container_class')),
                service('.virtual_request_stack')->ignoreOnInvalid(),
            ])
            ->tag('monolog.logger', ['channel' => 'profiler'])
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/logger.html.twig', 'id' => 'logger', 'priority' => 300])

        ->set('data_collector.time', TimeDataCollector::class)
            ->args([
                service('kernel')->ignoreOnInvalid(),
                service('debug.stopwatch')->ignoreOnInvalid(),
            ])
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/time.html.twig', 'id' => 'time', 'priority' => 330])

        ->set('data_collector.memory', MemoryDataCollector::class)
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/memory.html.twig', 'id' => 'memory', 'priority' => 325])

        ->set('data_collector.router', RouterDataCollector::class)
            ->tag('kernel.event_listener', ['event' => KernelEvents::CONTROLLER, 'method' => 'onKernelController'])
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/router.html.twig', 'id' => 'router', 'priority' => 285])
    ;

    // only if symfony/console package is installed
    if (class_exists(CommandDataCollector::class)) {
        $container->services()
            ->set('.data_collector.command', CommandDataCollector::class)
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/command.html.twig', 'id' => 'command', 'priority' => 335])
        ;
    }
};


Review comment (suggestion):
This config file must not define services conditionally, definition needs to be removed from FrameworkExtension instead which has an `hasConsole()` method for this purpose. 

Code after:
        ->set('data_collector.logger', LoggerDataCollector::class)
            ->args([
                service('logger')->ignoreOnInvalid(),
                \sprintf('%s/%s', param('kernel.build_dir'), param('kernel.container_class')),
                service('.virtual_request_stack')->ignoreOnInvalid(),
            ])
            ->tag('monolog.logger', ['channel' => 'profiler'])
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/logger.html.twig', 'id' => 'logger', 'priority' => 300])

        ->set('data_collector.time', TimeDataCollector::class)
            ->args([
                service('kernel')->ignoreOnInvalid(),
                service('debug.stopwatch')->ignoreOnInvalid(),
            ])
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/time.html.twig', 'id' => 'time', 'priority' => 330])

        ->set('data_collector.memory', MemoryDataCollector::class)
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/memory.html.twig', 'id' => 'memory', 'priority' => 325])

        ->set('data_collector.router', RouterDataCollector::class)
            ->tag('kernel.event_listener', ['event' => KernelEvents::CONTROLLER, 'method' => 'onKernelController'])
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/router.html.twig', 'id' => 'router', 'priority' => 285])

        ->set('.data_collector.command', CommandDataCollector::class)
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/command.html.twig', 'id' => 'command', 'priority' => 335])
    ;
};