title: How to inject entity depencies into a controller in symfony 5.2?
body: <p>I'm a beginner in symfony and I would like to inject my post entity into a method of my controller.</p>
  <p>However, I've the following error fired :</p>
  <pre><code>Unable to guess how to get a Doctrine instance from the request information for parameter &quot;post&quot;.
  </code></pre>
  <p>Here is my code :</p>
  <pre class="lang-php prettyprint-override"><code>/**
   * @Route(&quot;/post/article/new&quot;, name=&quot;new.html.twig&quot;)
   * @param Request $request
   * @param Posts $posts
   * @return Response
  */
  public function newArticle(Request $request, Posts $posts): Response
  {
      $post = $posts;
      $article = new Articles();
      $post-&gt;setAuthor(1);
      $form =  $this-&gt;createForm(PostsType::class, $post);
      $form-&gt;handleRequest($request);
  
      if($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
          $this-&gt;em-&gt;persist($post);
          $this-&gt;em-&gt;flush();
          $article-&gt;setPost($post-&gt;getId());
          $themes = $form-&gt;get('themes')-&gt;getData();
          $article-&gt;setThemes(implode(',', $themes));
          $this-&gt;em-&gt;persist($post);
          $this-&gt;em-&gt;flush();
  
          return  $this-&gt;redirectToRoute('home.html.twig');
      }
  
      return $this-&gt;render('post/article.html.twig', [
          'formArticle' =&gt; $form-&gt;createView()
      ]);
  }
  </code></pre>