m開發rest by zf。 這是我的用戶控制器。rest api action
<?php
class UserController extends Zend_Rest_Controller
{
public function init()
{
$this->_helper->viewRenderer->setNoRender(true);
}
public function indexAction()
{
$this->getResponse()
->appendBody("From indexAction() returning all articles");
}
public function getAction()
{
$this->getResponse()
->appendBody("From getAction() returning the requested article");
}
public function postAction()
{
$this->getResponse()
->appendBody("From postAction() creating the requested article");
}
public function putAction()
{
$this->getResponse()
->appendBody("From putAction() updating the requested article");
}
public function deleteAction()
{
$this->getResponse()
->appendBody("From deleteAction() deleting the requested article");
}
}
?>
通過運行此網址http://quickstart.local/user/
m到處
From indexAction() returning all articles
,並通過運行這個網址http://quickstart.local/user/1
米越來越
From getAction() returning the requested article
如何測試POST,PUT,刪除操作。
感謝
如果我這樣做http://quickstart.local/user/delete/它也稱爲getaction。 – XMen 2011-01-06 10:29:08
嘗試重命名你的行動到一些其他的行動,然後再試一次 – lampdev 2011-01-06 10:31:35