CodeIgniter Rest API(Phil Sturgeon)-如何切碎一个非常大的API文件
我一直在构建一个rest api(使用Phil Sturgeons Codeigniter Restserver),我一直在密切关注以下教程:CodeIgniter Rest API(Phil Sturgeon)-如何切碎一个非常大的API文件,api,codeigniter,rest,Api,Codeigniter,Rest,我一直在构建一个rest api(使用Phil Sturgeons Codeigniter Restserver),我一直在密切关注以下教程: http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/ 我特别关注教程的这一部分: function user_get() { // respond with information about a user }
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
我特别关注教程的这一部分:
function user_get()
{
// respond with information about a user
}
function user_put()
{
// create a new user and respond with a status/errors
}
function user_post()
{
// update an existing user and respond with a status/errors
}
function user_delete()
{
// delete a user and respond with a status/errors
}
我一直在为api可以访问的每个数据库对象编写上述函数,而且:
function users_get() // <-- Note the "S" at the end of "user"
{
// respond with information about all users
}
函数用户\u get()//您可以像创建常规控制器一样创建api控制器;您可以对模型执行相同的操作
application/controllers/api/users.php
class Users extends REST_Controller{
function user_post(){
$this->users_model->new_user()
...
POST index.php/api/user
--
我还希望将当前的模型函数(非api相关函数)与api使用的函数分开
我不明白为什么你不能使用相同的方法,只要它们返回你需要的
application/controllers/api/transactions.php
class Transactions extends REST_Controller{
function transaction_get(){
$this->transactions_model->get()
...
GET index.php/api/transaction