Depuis que j'ai migré vers AWS et mise à jour vers PHP 5.4 et Zend 1.12, j'ai un problème avec les méthodes PUT & DELETE.Zend 1.12 Rest PUT méthode non autorisée
Un exemple rapide:
/** 1,12 ** Zend/
/**/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
Résultat: obtenir ===> OK
curl -X PUT http://XXXX/rest/MS4xMjU2LjEyNTguMTI2MS4tbW9kZWxzXGNvcmVcbW9kZWxcZXhlcmNpc2VcZXhlcmNpc2VfcXVlc3Rpb24tMTQy
Résultat:
<!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>
===> Non OK
Je n'ai pas utiliser WebDav (ou autre) Plugin Apache pour activer la requête PUT/DELETE. Le gestionnaire PHP s'occupe de cela, pas d'Apache. Alors pourquoi, le GET est OK, et le PUT pas? Pourquoi Apache dit quelque chose à propos de index.php au lieu de /rest/RestController.php?
J'ai vu que Zend met à jour son Zend_Rest_Controller depuis 1.12. Maintenant, je l'ai de déclarer la fonction « headAction », mais je ne trouve pas de documentation sur ce point ...
Si vous avez une idée ...
Merci,
Copie possible de [Comment activer et utiliser HTTP PUT et DELETE avec Apache2 et PHP?] (Http://stackoverflow.com/questions/2934554/how-to-enable-and-use-http-put-and -delete-with-apache2-and-php) –