m developing rest api by zf.
this is my user controller.
<?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");
}
}
?>
By running this url http://quickstart.local/user/ m getting
From indexAction() returning all articles
and by running this url http://quickstart.local/user/1 m getting
From getAction() returning the requested article
how can i test post, put , delete action.
Thanks
Try to send POST, PUT and DELETE request via CURL to your controller’s URL.. Zend_Rest_Controller will automatically route that request to appropriate action.
Thanks!