I am working on creating an application with having an HMVC structure in codeigniter and i also require API Centric application , so i used https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc for HMVC and Rest_Controller of Phil Sturgeon, now everything is working fine , but the problem is for each controller in the module i have to add the static path
require APPPATH.'modules/modulename/libraries/REST_Controller.php';
i want to make this path dynamic , or auto load libraries for each module in the module's library folder, adding library name in the module/config/autoload.php is not working for me , as i think the reason is the code flow of application, first the application flow goes to the controller and it gets to my class extending the REST_Controller and gives the error , unable to load the REST_Controller Class
Note: if i put the Rest_Controller.php and Format.php in the application/libraries/ folder, everything works fine , but i want this to be modular , and make the module restful
how can i load libraries specifically from the module/libraries how to make it proper modular, so that there should be a complete instance of codeigniter in the module ,it should work freely, including the files loaded from the main application.
My folder structure is as follows
application
- - modules
- - - - modulename
- - - - - - controller
- - - - - - libraries
- - - - - - config
- - - - - - models
- - - - - - views
My Rest_Controller Class in the application/modules/module_name/libraries/Rest_Controller.php
abstract class REST_Controller extends MX_Controller
My Controller Class in application/modules/module_name/controllers/User.php
require APPPATH.'modules/modulename/libraries/REST_Controller.php';
class User extends REST_Controller
{
this works fine but if i remove the require line from the top , it doesn't work and even if i add the library name to autoload.php in the /modulename/config/autoload.php
it doesn't work My autoload.php /application/modules/modulename/config/autoload.php
<?phpif ( ! defined('BASEPATH')) exit('No direct script access allowed');
$autoload['packages'] = array();
$autoload['libraries'] = array('database', 'session','modulename/REST_Controller');
$autoload['helper'] = array('url', 'file');
$autoload['config'] = array();
$autoload['language'] = array();
$autoload['model'] = array();
and autoload.php in my application/config/autoload.php is empty, means no autoload mentioned
Fatal error: Class 'REST_Controller' not found in /application/modules/modulename/controllers/User.php** – King Khan Jun 17 '14 at 09:17