您好我試圖使API發送數據封裝與JSON。cakephp如何發送數據從控制器查看與json
作爲cakephp的手冊所述,我添加擴展在routes.php文件
$routes->extensions(['json]);
,我已經取得了控制器的索引函數。
public function index(){
$item = $this->Items->find('all');
$this->set(['items' => $items, '_serialize' => ['items']]);
}
這裏是問題所在。
我應該怎樣做才能讓api封裝成json?
請幫忙。
謝謝
$this->Items->find('all');
哇!!非常感謝你讓我知道。我錯誤地理解了Cake2.x Book中的REST手冊。謝謝!!!!!你真棒! – 2014-11-24 01:54:24