I'm trying to setup a REST API in Codeigniter following this example: /
But before anything, I want to make sure I can invoke the user_get() function with calling
.php/helloworld/user/id/1/format/json
and I thought the oute would be a simple "user_get called"
<?php
require("application/libraries/REST_Controller.php");
class Helloworld extends REST_Controller{
function user_get()
{
echo "user_get called";
}
}
?>
But instead, I got this error: An Error Was Encountered Unable to load the requested class: format
What was wrong? Thanks!!
I'm trying to setup a REST API in Codeigniter following this example: http://net.tutsplus./tutorials/php/working-with-restful-services-in-codeigniter-2/
But before anything, I want to make sure I can invoke the user_get() function with calling
http://mysite./myApp/index.php/helloworld/user/id/1/format/json
and I thought the oute would be a simple "user_get called"
<?php
require("application/libraries/REST_Controller.php");
class Helloworld extends REST_Controller{
function user_get()
{
echo "user_get called";
}
}
?>
But instead, I got this error: An Error Was Encountered Unable to load the requested class: format
What was wrong? Thanks!!
Share Improve this question asked Aug 9, 2011 at 18:24 William ShamWilliam Sham 13.2k11 gold badges51 silver badges67 bronze badges4 Answers
Reset to default 14There is also a file called format.php which you have to copy from the REST_Controller package. That does the magic
import into your codeigniter library, Format.php. get the file here https://github./philsturgeon/codeigniter-restserver/blob/master/application/libraries/Format.php
Does it tell you at which line this error happen? It looks like you need to define a class called "format" somewhere.
Check this line in file REST_Controller.php
// This library is bundled with REST_Controller 2.5+, but will eventually be part of CodeIgniter itself
$this->load->library('WHEREDOYOUHAVETHEFILE REST_Controller.php/format');