我遇到了由Chris Kacerguis維護的流行的REST API控制器的問題。 我已經導入了三個文件Format.php,REST_Controller.php和rest.php,並將它們放在我的codeIgniter文件結構中的適當位置。 我創建了一個用戶控制器,它看起來像這樣:在Codeigniter和REST API服務中找不到類'REST_Controller'
<?php
require_once APPPATH.'libraries/REST_Controller.php';
class Users extends REST_Controller{
public function index_get()
{
// Display all users
$this->response("Get method");
}
public function index_post()
{
// Create a new user
$this->response("Post method");
}
}
?>
我不斷收到寫着一個錯誤信息:「類‘REST_Controller’未找到」當我瀏覽到我的終點:http://localhost/api_test/index.php/users
任何想法我做錯了?
想必是找到在'require_once'行的文件,否則會報告說,它無法找到該文件(見[這個問題](http://stackoverflow.com/questions/9242788/apppath-codeigniter-doesnt-work-on-server))。你能證實該類實際上是在該文件中定義的嗎?也許通過在該文件中添加'print' /'echo'和/或'die'語句來調試它,以確保它達到那個點 –
從http://www.filetolink.com/a720227fd5下載最新代碼 –