title: How can I generate an unique id in Symfony 4?
body: <p>I want to create a unique id, so in my <code>Controller.php</code>, I write this:</p>
  
  <pre><code>use Symfony\Component\Validator\Constraints\Uuid;
  </code></pre>
  
  <p>and later in my function:</p>
  
  <pre><code>$unique_id = $this-&gt;uuid = Uuid::uuid4();
  </code></pre>
  
  <p>But I get the error message:</p>
  
  <blockquote>
    <p>Attempted to call an undefined method named "uuid4" of class
    "Symfony\Component\Validator\Constraints\Uuid".</p>
  </blockquote>