我将使用REST_Controller.php来制作休息api . (在ubnatu 15上使用codeigniter v3)
来自链接https://github.com/chriskacerguis/codeigniter-restserver
在调用localhost / rest_api_ci / api / example / user / 1时
Showing me error
Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21
A look of Example.php file
<?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()
{
4 回答
后
你需要添加名称空间:
...几分钟前我遇到了这个问题,它和我一起工作
我认为它的路径问题,给出了相同的答案here
希望它能帮助你或其他人 .
谢谢
改变你的网址
至
删除
REST_Server.php
和Format.php
中不必要的命名空间帮助了我 .