Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.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
Php Codeigniter服务器REST_Php_Codeigniter_Rest - Fatal编程技术网

Php Codeigniter服务器REST

Php Codeigniter服务器REST,php,codeigniter,rest,Php,Codeigniter,Rest,通过遵循本教程,我在codeigniter rest v 2.1.1上创建了一个服务器。 我在文件REST\u Controller.php中有一个错误 // How is this request being made? POST, DELETE, GET, PUT? $this->request->method = $this->_detect_method(); 我的代码: <?php require(APPPATH . 'libraries/

通过遵循本教程,我在codeigniter rest v 2.1.1上创建了一个服务器。

我在文件REST\u Controller.php中有一个错误

// How is this request being made? POST, DELETE, GET, PUT?
        $this->request->method = $this->_detect_method();
我的代码:

<?php

require(APPPATH . 'libraries/REST_Controller.php');

class Api extends REST_Controller {

    function test_get() {
    $this->response(array('success' => 'Yes it is working'), 200);
    }

}
如何修复错误?

在Rest\u controller.php中尝试此代码

添加这些行

if(!is_object($this->request))
         {
            $this->request= new stdClass();
         }
年初

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

   $this->load->config('rest');

  //some where here like 

   if(!is_object($this->request))
         {
            $this->request= new stdClass();
         }

$this->request->method = $this->_detect_method();


......
....
...
}

这并没有解决我的问题。
publict function __construct()
{
   parent::__construct();

   $this->load->config('rest');

  //some where here like 

   if(!is_object($this->request))
         {
            $this->request= new stdClass();
         }

$this->request->method = $this->_detect_method();


......
....
...
}