简体   繁体   中英

Loading Library From A new folder in Codeigniter

In my application i want to load a library from a new folder. My application codeigniter.In my root folder there have module folder there have a library file i want to load that library in my model page.

This is my code:

$this->load->library('./modules/libraryname');  

When i loading library this code I got an error message.

Unable load the requested library

What is the mistake in my code.? When i copy the library file to codeigniter's library folder and changing the code as :

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

Then it will load the library without error.

But i need to load this from only module folder.What i do?

This example shows how to change the default directory for changing where classes are extended, specifically here to extend Controller_CI - I have used CH to denote CHILD class

In boot:

if (is_dir('<path>/extend/codeigniter_CH/')) {
    define('APPEXTEND_PATH', '<path>/extend/codeigniter_CH/');
} else {
    exit("<br />Error<br /><br />Your application extend folder path:<br />" . APPEXTEND_PATH . "<br />does not appear to be set correctly. Please open the following file and correct this: " . SELF);
}

in Controller.php class (system) at line 230 of orig file

if (file_exists(APPEXTEND_PATH . config_item('subclass_prefix') . 'Controller.php')) {
    require APPEXTEND_PATH . config_item('subclass_prefix') . 'Controller.php';
} else {
    exit("not found " . APPEXTEND_PATH . config_item('subclass_prefix') . 'Controller.php');

}

Codeigniter looks for library in application/library 1st, then system/library. You have only these two options. The folders are given for that purpose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM