我是Zend框架和MVC類型編程的新手(不是PHP),我試圖使用Zend Framework爲我的服務器上的數據提供API訪問。使用Zend_Rest_Controller提供REST API訪問時的正確代碼結構
我使用Chris Danielson的文章(http://www.chrisdanielson.com/2009/09/02/creating-a-php-rest-api-using-the-zend-framework/)作爲基礎。
我想提供以下格式的數據訪問:
(a) http://www.example.com/api/createevent
Data will be POSTed here, success will return an id, otherwise an
error message/code
(b) http://www.example.com/api/geteventdetails/1234
GET request will return data
(c) http://www.example.com/api/getregistrationdetails/1234
GET request will return data
(d) http://www.example.com/api/getregistrationdetails/1234/567
GET request will return data
問題:
有它位於\ API \程序\控制器\ VersionController默認文件。 PHP,它可以處理類型爲:http://www.example.com/api/version的URL。我應該創建一個獨立文件,它位於:\ api \ application \ controllers \ GeteventdetailsController.php,它處理類型(b)的請求(並且每種類型的請求都有一個請求)?如果不是,我應該在哪裏放置我的代碼來處理這些多種請求類型?
我怎樣才能得到參數(b)傳遞給(d)?
要做(b)到(d)的請求,我需要從服務器的數據庫中獲取信息。我應該在哪裏放置執行實際MySQL查詢的代碼?
+1 - well put !! – 2011-03-16 22:31:49