我将使用REST_Controller.php来制作rest。(在ubnatu 15上使用代码点火器v3 )
从链接https://github.com/chriskacerguis/codeigniter-restserver
如何调用localhost/rest_api/api/示例/user/1
向我显示错误
Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21Example.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()
{发布于 2016-12-28 07:51:18
将您的url改为
localhost/rest_api_ci/api/example/user/1至
http://localhost/rest_api_ci/index.php/api/Example/users发布于 2016-12-29 09:24:35
删除REST_Server.php和Format.php中不必要的命名空间对我有帮助。
发布于 2017-04-18 16:05:33
之后
require(APPPATH.'libraries/REST_Controller.php');您需要添加名称空间:
// use namespace
use Restserver\Libraries\REST_Controller;..。几分钟前我遇到了这个问题,它对我起了作用。
https://stackoverflow.com/questions/41357516
复制相似问题