使用restful api在代码点火器篝火中获取404错误


Getting 404 error in codeigniter bonfire using restful api

我在为CI篝火设置Rest Server时遇到问题。

我按照以下说明安装了它:https://github.com/philsturgeon/codeigniter-restserver.

我创建了一个新的控制器,看起来像这样:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require(APPPATH.'libraries/REST_Controller.php');
class Hello extends REST_Controller{
function user_get()  
{  
    $data = array('returned: '. $this->get('id'));  
    $this->response($data);  
}  
function user_post()  
{         
    $data = array('returned: '. $this->post('id'));  
    $this->response($data);  
}  
function user_put()  
{         
    $data = array('returned: '. $this->put('id'));  
    $this->response($data);  
}  
function user_delete()  
{  
    $data = array('returned: '. $this->delete('id'));  
    $this->response($data);  
}  
}
?>

现在,我的网址是这样的:http://website.com/public/admin/hello/user/id/1这里我得到一个404错误页面。

我错过了什么?我是否向管制员提出了糟糕的请求,或者是否存在路线问题?任何帮助都将不胜感激。

好吧,我的问题似乎是关于代码点火器路由。评论这些行解决了我的问题:

$route[SITE_AREA .'/([a-z_]+)/(:any)/(:any)/(:any)/(:any)/(:any)']      =    "$2/$1/$3/$4/$5/$6";
$route[SITE_AREA .'/([a-z_]+)/(:any)/(:any)/(:any)/(:any)']     = "$2/$1/$3/$4/$5";
$route[SITE_AREA .'/([a-z_]+)/(:any)/(:any)/(:any)']        = "$2/$1/$3/$4";
$route[SITE_AREA .'/([a-z_]+)/(:any)/(:any)']       = "$2/$1/$3";
$route[SITE_AREA .'/([a-z_]+)/(:any)']              = "$2/$1/index";

但更好的是,在这些路线之上写一条新路线就是做好这项工作。

$route[SITE_AREA .'/hello/(:any)']  = "admin/hello/$1";

希望有人会觉得这很方便。