Автозагрузка кода сервера API Codeigniter - PullRequest
0 голосов
/ 11 октября 2018

У меня точно такая же проблема с: контроллером автозагрузки Codeigniter 3

, который я хочу автоматически загружать в Libary, поэтому я не буду объявлять это:

use Restserver\Libraries\REST_Controller;
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 */
//To Solve File REST_Controller not found
require APPPATH . 'libraries/REST_Controller.php';
require APPPATH . 'libraries/Format.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
 */

в каждом контроллере.Я попытался расширить его core / MY_Controller, как предложено в ответе по ссылке, которую я предоставил выше, вот мой core / MY_Controller.php выглядит так:

<?php
use Restserver\Libraries\REST_Controller;
require APPPATH . 'libraries/REST_Controller.php';
require APPPATH . 'libraries/Format.php';

class MY_Controller extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();

    }

}

?>

и после запуска controller / Example.php, методы избиблиотека остальных API неизвестна.и с этой ошибкой:

Message: Call to undefined method Phone::get()

Filename: C:\xampp\htdocs\mainline\application\controllers\api\Phone.php

Line Number: 16

Example.php

class Phone extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function index_get()
    {

        $message = [
            'id' => 100, // Automatically generated by the model
            'name' => $this->get('name'),
            'email' => $this->get('email'),
            'message' => 'Invalid request'
        ];
        $this->set_response($message, REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code
    }
...