0

I'm using zendframework. Here i used getRequest() method outside the controller, inside the CliCommands class.But it through an error.

 PHP Fatal error:  Uncaught Error: Call to undefined method
 V1Command::getRequest().

Is there any way to use the getRequest() outside the controller?

UPDATE:

After using this:

$front = Zend_Controller_Front::getInstance();
$all = $front->getRequest()->getParams();

Now I'm getting this type of error:

Fatal error: Uncaught Error: Call to a member function getParams() on null

Anitha s
  • 43
  • 1
  • 9

1 Answers1

0

From inside the controller you can use any one of these

$all = $this->getRequest()->getParams();
$one = $this->getRequest()->getParam('key');

$all = $this->_request->getParams();
$one = $this->_request->getParam('key');

$all = $this->_getAllParams();
$one = $this->_getParam('key');

Or from outside the controller (and after the front controller is loaded):

$front = Zend_Controller_Front::getInstance();
$all = $front->getRequest()->getParams();
$one = $front->getRequest()->getParam('key');
Nawin
  • 1,653
  • 2
  • 14
  • 23