找不到Codeigniter类“ REST_Controller” [英] Codeigniter Class 'REST_Controller' not found

查看:147
本文介绍了找不到Codeigniter类“ REST_Controller”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了由Chris Kacerguis维护的流行的REST API codeigniter的问题,我创建了一个看起来像这样的Datadiri控制器:

I'm having a problem with the popular REST API codeigniter maintained by Chris Kacerguis.I created a Datadiri controller that looks like this:

<?php
require (APPPATH.'/libraries/REST_Controller.php');

class Datadiri extends REST_Controller{
    function __construct($config = 'rest'){
        parent::__construct($config);
    }
    //tampilkan data
    function index(){
        $buku = $this->db->get('perpustakaan');
        $this->response($buku, 200);
    }
}

这是Rest_controller.php
https://github.com/chriskacerguis/codeigniter-restserver/ blob / master / application / libraries / REST_Controller.php

This is Rest_controller.php https://github.com/chriskacerguis/codeigniter-restserver/blob/master/application/libraries/REST_Controller.php

但仍然相同,未找到错误类 REST_Controller。我该如何解决呢?

But Still same, the error Class 'REST_Controller' not found. how can i solve this?


致命错误:在
中找不到类 REST_Controller C:\xampp\htdocs
第4行上的CodeIgniter应用程序控制器controllerddatairi.php遇到PHP错误

Fatal error: Class 'REST_Controller' not found in C:\xampp\htdocs\CodeIgniter\application\controllers\datadiri.php on line 4 A PHP Error was encountered

严重性:错误

消息:未找到类 REST_Controller

Message: Class 'REST_Controller' not found

文件名:controllers / datadiri.php

Filename: controllers/datadiri.php

行号:4

回溯:


推荐答案

最后,问题解决了。
iam编辑application / config / config.php
来自: $ config ['subclass_prefix'] ='MY _';
至: $ config ['subclass_prefix'] ='REST _';

Finally the problem solved. iam edit application/config/config.php from : $config['subclass_prefix'] = 'MY_'; to : $config['subclass_prefix'] = 'REST_';

和Datadiri.php一样:

And Datadiri.php like this :

<?php
  use Restserver\Libraries\REST_Controller;
   class Datadiri extends REST_Controller{
       function __construct(){
           parent:: __construct();
       }
       function index_get(){
           $buku = $this->db->get('perpustakaan')->result();
           $this->response($buku, 200);
       }
   }

这篇关于找不到Codeigniter类“ REST_Controller”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆