Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Appears it was rather simple. I've put together a Restful Controller template using the Zend_Rest_Controller Abstract. Simply replace the no_results return values with a native php object containing the data you want returned. Comments welcome.</p> <pre><code>&lt;?php /** * Restful Controller * * @copyright Copyright (c) 2009 ? (http://www.?.com) */ class RestfulController extends Zend_Rest_Controller { public function init() { $config = Zend_Registry::get('config'); $this-&gt;db = Zend_Db::factory($config-&gt;resources-&gt;db); $this-&gt;no_results = array('status' =&gt; 'NO_RESULTS'); } /** * List * * The index action handles index/list requests; it responds with a * list of the requested resources. * * @return json */ public function indexAction() { // do some processing... // Send the JSON response: $this-&gt;_helper-&gt;json($this-&gt;no_results); } // 1.9.2 fix public function listAction() { return $this-&gt;_forward('index'); } /** * View * * The get action handles GET requests and receives an 'id' parameter; it * responds with the server resource state of the resource identified * by the 'id' value. * * @param integer $id * @return json */ public function getAction() { $id = $this-&gt;_getParam('id', 0); // do some processing... // Send the JSON response: $this-&gt;_helper-&gt;json($this-&gt;no_results); } /** * Create * * The post action handles POST requests; it accepts and digests a * POSTed resource representation and persists the resource state. * * @param integer $id * @return json */ public function postAction() { $id = $this-&gt;_getParam('id', 0); $my = $this-&gt;_getAllParams(); // do some processing... // Send the JSON response: $this-&gt;_helper-&gt;json($this-&gt;no_results); } /** * Update * * The put action handles PUT requests and receives an 'id' parameter; it * updates the server resource state of the resource identified by * the 'id' value. * * @param integer $id * @return json */ public function putAction() { $id = $this-&gt;_getParam('id', 0); $my = $this-&gt;_getAllParams(); // do some processing... // Send the JSON response: $this-&gt;_helper-&gt;json($this-&gt;no_results); } /** * Delete * * The delete action handles DELETE requests and receives an 'id' * parameter; it updates the server resource state of the resource * identified by the 'id' value. * * @param integer $id * @return json */ public function deleteAction() { $id = $this-&gt;_getParam('id', 0); // do some processing... // Send the JSON response: $this-&gt;_helper-&gt;json($this-&gt;no_results); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload