Question

I have just finished setting up an HMVC CodeIgniter following the steps here.

I am now trying to create a module "api" which I wish to use Phil Sturgeon's REST library.

It states here that I need to extend the MX_Controller rather than the CI_Controller and I did.

My initial setup was like this

application
--modules
----api
------config
------controller
------libraries

I kept getting an error with loading Rest_Controller so I have tried moving the REST_Controller and Format libraries to application/libraries that seemed to fix the loading issue but now i am getting the error below whenever i try to access it via http://example.com/codeigniter/index.php/api/example/user/id/1/format/json

"An Error Was Encountered

Unable to load the requested class: security"

I am expecting for the output to be "{"id":1,"name":"Some Guy","email":"example1@example.com","fact":"Loves swimming"}"

What am I missing? Would it be possible to keep the REST_Controller and Format libraries under the api module? If so, how?

Was it helpful?

Solution

Source

Open Rest_Controller.php go to line 173 and change the following code

$this->load->library('security');

to

$this->load->helper('security');

EDIT:

To have the REST_Controller and Format libraries under the api module.

Move the REST_Controller to api/controllers/REST_Controller.php and Format to api/libraries/Format.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top