title: Symfony 5: How can I prevent an Event Subscriber to fire twice with the Profiler (Web Debug Toolbar) active?
body: <p>I created a subscriber which executes another class-&gt;method, which creates a database entry. I can see that the subscriber fires twice, because the database entries are always entered double. I deactivated the Profiler (the Web Debug Toolbar) and that fixed the issue.</p>
  <p>Here my Subscriber:</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  namespace App\EventSubscriber;
  
  use Psr\Log\LoggerInterface;
  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  use Symfony\Component\HttpKernel\Event\ResponseEvent;
  use Symfony\Component\HttpKernel\Event\RequestEvent;
  use Symfony\Component\HttpKernel\KernelEvents;
  use App\Repository\UserRepository;
  
  class ExampleSubscriber implements EventSubscriberInterface
  {
      public static function getSubscribedEvents() {
          return [
              KernelEvents::RESPONSE =&gt; [
                  ['onKernelResponsePre', 10],
                  ['onKernelResponsePost', -10],
              ],
              RequestEvent::class =&gt; 'onKernelRequest',
          ];
      }
  
      public function __construct(
          LoggerInterface $logger,
          UserRepository $user
      ) {
          $this-&gt;logger = $logger;
          $this-&gt;user   = $user;
      }
  
      public function onKernelResponsePre(ResponseEvent $event)
      {
          // ...
      }
  
      public function onKernelResponsePost(ResponseEvent $event)
      {
          // ...
      }
  
      public function onKernelRequest(RequestEvent $event)
      {
          $db_data = $this-&gt;user-&gt;findUserByUsername($user_name);
  
          $write_db_entry = $this-&gt;user-&gt;writeUserData($db_data['user_id']);
          $this-&gt;logger-&gt;info('Just checking if this message shows twice. It does not.');
      }
  }
  </code></pre>
  <p>How can I get the code in &quot;onKernelRequest&quot; to just execute once <strong>and</strong> have the Profiler active? It could be in any event, but should execute before the controller gets called.</p>
  <p>Thank you in advance for your help.</p>