我将使用REST_Controller.php来制作休息api。 (在ubnatu 15上使用codeigniter v3)
来自链接https://github.com/chriskacerguis/codeigniter-restserver
打电话 本地主机/ rest_api_ci / API /示例/用户/ 1
显示错误
Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21
看看Example.php文件
<?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()
{
答案 0 :(得分:0)
从
更改您的网址localhost/rest_api_ci/api/example/user/1
到
http://localhost/rest_api_ci/index.php/api/Example/users
答案 1 :(得分:0)
删除REST_Server.php
和Format.php
中不必要的命名空间帮助了我。
答案 2 :(得分:0)
之后
require(APPPATH.'libraries/REST_Controller.php');
您需要添加命名空间:
// use namespace
use Restserver\Libraries\REST_Controller;
...几分钟前我遇到过这个问题并且它与我一起工作
答案 3 :(得分:0)
我认为这是路径问题,给出了相同的答案here
希望对您或其他人有帮助。
谢谢