title: How to get the request parameters in Symfony 2?
body: <p>I am very new to symfony. In other languages like java and others I can use <code>request.getParameter('parmeter name')</code> to get the value.</p>
  
  <p>Is there anything similar that we can do with symfony2.<br>
  I have seen some examples but none is working for me. Suppose I have a form field with the name <strong>username</strong>. In the form action I tried to use something like this:</p>
  
  <pre><code>$request = $this-&gt;getRequest();
  $username= $request-&gt;request-&gt;get('username'); 
  </code></pre>
  
  <p>I have also tried </p>
  
  <p><code>$username = $request-&gt;getParameter('username');</code> </p>
  
  <p>and</p>
  
  <pre><code>$username=$request-&gt;request-&gt;getParameter('username');
  </code></pre>
  
  <p>But none of the options is working.However following worked fine:</p>
  
  <pre><code>foreach($request-&gt;request-&gt;all() as $req){
      print_r($req['username']);
  }
  </code></pre>
  
  <p>Where am I doing wrong in using <code>getParameter()</code> method. Any help will be appreciated.</p>