get post parameters in zend framework in "put" method

keen picture keen · Jan 21, 2014 · Viewed 8.9k times · Source

I am getting get parameters using this

$this->params()->fromQuery('KEY');

I found two way to get POST parameters

//first way
$this->params()->fromPost('KEY', null);

//second way
$this->getRequest()->getPost();

Both of this working in "POST" method but now in a "PUT" method if I pass values as a post parameters.

How I can get post parameters in "PUT" method?

Answer

npetrovski picture npetrovski · Jan 30, 2014

I guess the right way of doing that is by using Zend_Controller_Plugin_PutHandler:

// you can put this code in your projects bootstrap
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Zend_Controller_Plugin_PutHandler());

and then you can get your params via getParams()

foreach($this->getRequest()->getParams() as $key => $value) {
    ...
}

or simply

$this->getRequest()->getParam("myvar");