2012-12-28 60 views
1

我正在使用phil sturgeon的codeigniter休息服務器。我遵循net.tutsplus教程爲restfull服務here。我已經在本地安裝了其他服務器,並在安裝到服務器之前查看它是如何工作的。codeigniter休息服務器問題

我從開始有很多問題。 我包含在我的主控制器和線後REST_Controller.php文件時,我這樣做:

class Courses extends REST_Controller { 

    function index(){ 
    $this->load->view('index'); 
    } 

} 

它給錯誤說: 致命錯誤:類'REST_Controller找不到。 但如果我用CI_Controller替換REST_Controller,它會加載索引視圖。 我被困在這個4小時,沒有任何工作是我的方式。 需要你的意見guyz 日Thnx提前

回答

0

它應該是這樣的

class Courses extends REST_Controller { 

function index_get(){ 
    $this->response(array('success' => 'Yes it is working'), 200); 
} 

} 
0

添加此函數在您的config.php文件的頂部。通過這種方式,您不需要將任何文件包含到擴展REST_Controller的任何控制器中。

function __autoload($classname) { 
    if (strpos($classname, 'CI_') !== 0) { 
     $file = APPPATH . 'libraries/' . $classname . '.php'; 
     if (file_exists($file) && is_file($file)) { 
      @include_once($file); 
     } 
    } 
}