Restful Codeigniter

时间:2017-08-02 14:28:49

标签: php rest api codeigniter

我尝试使用Restful Codeigniter制作Restful API,我完成了所有安装要求,并下载了所有库,但是当我制作此代码时

<?php
require APPPATH . '/libraries/REST_Controller.php';

class api extends REST_Controller{
  function __construct(){
    parent:: __construct();
  }

  function get_osama(){
    $this -> response('Hello Word');
  }
}
?>

,在Postman中显示错误:

</style>
        </head>
        <body>
            <div id="container">
                <h1>An Error Was Encountered</h1>
                <p>Your C:\xampp\htdocs\api\application\config/rest.php file does not appear to contain a valid configuration array.</p>
            </div>
        </body>
    </html>

并在浏览器中也给我这个错误:

  

遇到错误

     

您的C:\ xampp \ htdocs \ api \ application \ config / rest.php文件似乎不包含有效的配置数组。

1 个答案:

答案 0 :(得分:1)

使用$ this - &gt; response(array('Hello Word'));相反,如果$ this - &gt;回应('Hello Word');