Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
REST_Controller.php在codeigniter中不工作_Codeigniter - Fatal编程技术网

REST_Controller.php在codeigniter中不工作

REST_Controller.php在codeigniter中不工作,codeigniter,Codeigniter,我将使用REST_Controller.php制作RESTAPI。(在ubnatu 15上使用codeigniter v3) 从链接 随叫随到 localhost/rest\u api\u ci/api/example/user/1 向我显示错误 Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21

我将使用REST_Controller.php制作RESTAPI。(在ubnatu 15上使用codeigniter v3)

从链接

随叫随到 localhost/rest\u api\u ci/api/example/user/1

向我显示错误

Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require(APPPATH.'libraries/REST_Controller.php');


/**
 * This is an example of a few basic user interaction methods you could use
 * all done with a hardcoded array
 *
 * @package         CodeIgniter
 * @subpackage      Rest Server
 * @category        Controller
 * @author          Phil Sturgeon, Chris Kacerguis
 * @license         MIT
 * @link            https://github.com/chriskacerguis/codeigniter-restserver
 */
class Example extends REST_Controller {

    function __construct()
    {
查看Example.php文件

Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require(APPPATH.'libraries/REST_Controller.php');


/**
 * This is an example of a few basic user interaction methods you could use
 * all done with a hardcoded array
 *
 * @package         CodeIgniter
 * @subpackage      Rest Server
 * @category        Controller
 * @author          Phil Sturgeon, Chris Kacerguis
 * @license         MIT
 * @link            https://github.com/chriskacerguis/codeigniter-restserver
 */
class Example extends REST_Controller {

    function __construct()
    {
从更改您的url

localhost/rest_api_ci/api/example/user/1


删除
REST\u Server.php
Format.php
中不必要的名称空间对我很有帮助

之后

require(APPPATH.'libraries/REST_Controller.php');
您需要添加名称空间:

// use namespace

use Restserver\Libraries\REST_Controller;

。。。几分钟前我遇到了这个问题,它对我起到了作用

我认为这是路径问题,给出了相同的答案
希望它能帮助你或其他人。

谢谢

在项目中,您将rest\u controller.php放在哪里?在libraries/rest\u controller.php中,一切都在正确的位置。我正在使用.htaccess文件删除index.phpso如果您正在使用,您的url必须是localhost@vipulsharma您是否也在使用MX_控制器?与@vipul sharma仍然相同:回答providedplace example.php位于api文件夹之外,并更改url不起作用,因为“类示例扩展REST_控制器”不起作用找到的任何解决方案?