title: Zend framework 2 REST API : set Request parameters
body: <p>I am new to PHP frameworks and building REST API on Zend Framework 2. I want to add params to <code>Request</code>. I could not find method to add params so I'll do it by getting all params then, adding new params to them and then setting this new set of params to <code>Request</code>.
  I get params using</p>
  
  <pre><code>$this-&gt;params()-&gt;fromQuery()
  </code></pre>
  
  <p>but, I don't find any way to set params back to <code>Request</code>. Is there any method available for this?</p>
  
  <p><strong>EDIT :</strong> I tried below. Which is not giving desired result.</p>
  
  <p><strong>In Module.php :</strong> </p>
  
  <pre><code>public function onBootstrap(\Zend\Mvc\MvcEvent $e)
  {
      $em = $e-&gt;getApplication()-&gt;getEventManager();
      echo "Outside";
  
      $em-&gt;attach (MvcEvent::EVENT_DISPATCH, function(MvcEvent $e) {
  
          echo "Inside";
          $routeMatch = $e-&gt;getRouteMatch();
          $routeMatch-&gt;setParam("myParam", "paramValue");        
      });
  } 
  </code></pre>
  
  <p><strong>In my controller :</strong></p>
  
  <pre><code>echo "myParam : " . $this-&gt;params()-&gt;fromQuery('myParam');
  </code></pre>
  
  <p>Param value is <code>null</code> when I get it. This is on account of controller code is executed first(where I get param value) and then the <code>Dispatch</code> event is triggered(where I add param to RouteMatch).</p>
  
  <pre><code>Outside
  myParam : 
  Inside
  </code></pre>