2011-08-09 59 views
1

我試圖建立在一個笨REST API下面這個例子: http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/初學者問題笨REST_Controller

但任何事情之前,我要確保我可以調用user_get()函數調用與

http://mysite.com/myApp/index.php/helloworld/user/id/1/format/json

,我想結局會是一個簡單的 「user_get稱爲」

<?php 
require("application/libraries/REST_Controller.php"); 

class Helloworld extends REST_Controller{ 

    function user_get() 
    { 
     echo "user_get called"; 
    } 
} 
    ?> 

但是,我得到這個錯誤: 遇到了一個錯誤 無法加載所請求的類:格式

出了什麼問題? 謝謝!

回答

0

它是否告訴你在哪條線發生此錯誤?看起來您需要在某處定義一個名爲「format」的類。

13

還有一個名爲format.php的文件,您必須從REST_Controller包中複製該文件。 這確實神奇

+0

感謝它也適用於我 – Ali

0

檢查文件這一行REST_Controller.php

// This library is bundled with REST_Controller 2.5+, but will eventually be part of CodeIgniter itself 
$this->load->library('WHEREDOYOUHAVETHEFILE REST_Controller.php/format');