I'm trying to create a web application using a JavaScript framework (eg Extjs) for client side and Zend framework for server side.
I have read a lot about REST and I wanna use it in my application. I have created an Extjs form which asynchronously fetches data for country names, auto-completes usernames, etc.
How should I create my Zend framework controller? How many controllers should I create for just a single form? I have a getAction in my controller and the request is like: http://localhost/myproject/myform so if I wanna process different Get requests (eg, country names, cities, etc.) should I create a switch statement in my getAction for every resource or should I create different controllers for just one form until I don't have to use switch?
class IndexController extends Zend_Rest_Controller {
public function init() {
}
public function indexAction() {
}
public function getAction() {
$this->_helper->viewRenderer->setNoRender ( true );
//switch statement for diffrent resource requests goes here
}
public function postAction() {
$this->_helper->viewRenderer->setNoRender ( true );
}
public function putAction() {
$this->_helper->viewRenderer->setNoRender ( true );
}
public function deleteAction() {
$this->_helper->viewRenderer->setNoRender ( true );
}
}
What do you suggest? Should I create many controllers for just one extjs form?