title: How to create a Forbidden Response in Symfony2?
body: <p>I just discovered SensioLabsInsight and found very <a href="https://insight.sensiolabs.com/what-we-analyse">interesting tips</a> on how to write good code. It would be great if there was some explanation on why (or why not) something should be used - even for basic stuff like <code>exit</code> and <code>die</code>. It would help me to explain things to people I work with.</p>
  
  <p>So my question is specifically for AccessDeniedHttpException - it says:</p>
  
  <blockquote>
    <p>Symfony applications should not throw AccessDeniedHttpException</p>
  </blockquote>
  
  <p>So how do I return 403 Forbidden from the application controller or EventListener?<br>
  What is the best practice?</p>
  
  <p>To be honest I thought it would be</p>
  
  <pre><code>throw new AccessDeniedHttpException()
  </code></pre>
  
  <p>Since for 404 you have</p>
  
  <pre><code>throw $this-&gt;createNotFoundException()
  </code></pre>
  
  <p>But it looks like I was wrong.</p>