Since I migrated to AWS and update to PHP 5.4 and Zend 1.12, I have a problem with the PUT & DELETE methods.
A quick exemple :
/** Zend 1.12 **/
/** bootstrap / routes **/
$front = \Zend_Controller_Front::getInstance();
$front->setParam('bootstrap',$this);
//REST API
$router = $front->getRouter();
$restRoute = new Zend_Rest_Route($front, array(), array(
'default' => array('rest'),
));
$router->addRoute('rest', $restRoute);
/** restController **/
//module : default
class RestController extends \Zend_Rest_Controller
public function init(){
parent::init();
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
}
public function headAction(){}
public function indexAction()
{
Throw new AppException(Translator::translate('index not yet implemented...'));
}
public function getAction()
{
die('get');
}
public function putAction(){
die('put');
}
/* TestCase */
curl -X GET http://XXXX/rest/MS4xMjU2LjEyNTguMTI2MS4tbW9kZWxzXGNvcmVcbW9kZWxcZXhlcmNpc2VcZXhlcmNpc2VfcXVlc3Rpb24tMTQy
Result : get ===> OK
curl -X PUT http://XXXX/rest/MS4xMjU2LjEyNTguMTI2MS4tbW9kZWxzXGNvcmVcbW9kZWxcZXhlcmNpc2VcZXhlcmNpc2VfcXVlc3Rpb24tMTQy
Result :
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for the URL /index.php.</p>
<hr>
<address>Apache/2.2.16 (Debian) Server at XXXXX Port 80</address>
</body></html>
===> Not OK
I don't have to use WebDav (or other) Apache plugin to enable PUT/DELETE request. The PHP Handler deals with that, not Apache. So why, the GET is OK, and the PUT not? Why Apache says something about index.php instead of /rest/RestController.php?
I saw that Zend update its Zend_Rest_Controller since 1.12. Now, I've to declare the "headAction" function, but I didn't find documentation on this point...
If you have any idea...
Thanks,
Probably the problem is rooted in Apache configuration. Maybe you should go ahead and add something like
to your apache configuration.
Check out this answer.