title: Symfony Check if user exist in database
body: <p>I am looking for a solution in my controller to check before sending a form if the user already exists in the database. Here is my action on which I would like to implement this.</p>
  
  <pre><code>/**
   * Creates a new invite entity.
   *
   * @Route("/inscription", name="invite_new")
   * @Method({"GET", "POST"})
   */
  public function newAction(Request $request)
  {
      $invite = new Invite();
  
      $form = $this-&gt;createForm(InviteType::class, $invite);
  
      if ($request-&gt;isMethod('POST')) {
          $form-&gt;handleRequest($request);
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $em-&gt;persist($invite);
              $em-&gt;flush();
  
              $this-&gt;get('app_mailer')-&gt;sendMailInscriptionMjml($invite, $this-&gt;getParameter('client_mail_to'));
  
              $this-&gt;get('session')-&gt;getFlashBag()-&gt;add('success', 'Votre inscription à été pris en compte.');
          } else {
              $this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error', 'Une erreur est survenue.');
          }
  
          return $this-&gt;redirect($this-&gt;generateUrl('invite_show', array('id' =&gt; $invite-&gt;getId())));
      }
  
      return $this-&gt;render('@App/invite/new.html.twig', array(
          'invite' =&gt; $invite,
          'form' =&gt; $form-&gt;createView(),
      ));
  }
  </code></pre>
  
  <p>Thank you for your help</p>