私はREST/JSONを使用する傾向があります。これは、ほとんどの場合、最も簡単で高速です。 XML解析とZend FrameworkはRESTアプリケーションの作成を非常に簡単にサポートしています。さらに、の場合は、実際にはのサイズを変更する必要がある場合、ビューとデータのレイヤーを別のサーバーに分けることができます。私はしばしば、同じモジュール内に「普通の」コントローラーとRESTコントローラーを持っています。それはかなり簡単です。
GET/POST/PUT /アクションはHTTPリクエストの種類に対応して削除
class MyRestController extends Zend_Rest_Controller
{
public function init()
{
$this->_helper->viewRenderer->setNoRender(true);
}
public function indexAction()
{
}
public function getAction()
{
}
public function postAction()
{
}
public function putAction()
{
}
public function deleteAction()
{
}
}
そして、あなたはあなたのブートストラップでルートを初期化する必要があります。
protected function _initRestRoute()
{
$this->bootstrap('frontController');
$frontController = Zend_Controller_Front::getInstance();
$restRoute = new Zend_Rest_Route($frontController);
$frontController->getRouter()->addRoute('default', $restRoute);
}
いくつかの光読書:
を
http://www.techchorus.net/create-restful-applications-using-zend-framework
http://www.xfront.com/REST-Web-Services.html
http://www.develop.com/httpstatuscodesrest