在我的应用程序中,我想从一个新文件夹加载一个库。我的应用程序代码点火器。在我的根文件夹中有module
文件夹,有一个库文件,我想在我的模型页面中加载该库。
这是我的代码:
$this->load->library('./modules/libraryname');
当我加载这个库代码时,我收到了一条错误消息。
Unable load the requested library
我的代码中有什么错误。?当我将库文件复制到codeigniter的库文件夹并将代码更改为:时
$this->load->library('libraryname');
然后它将加载库而不会出错。
但我只需要从module
文件夹加载这个。我做什么?
Codeigniter首先在应用程序/库中查找库,然后是系统/库。你只有这两个选择。这些文件夹就是为了这个目的而提供的。
这个例子展示了如何更改默认目录以更改类的扩展位置,特别是在这里扩展Controller_CI-我用CH表示CHILD类
启动时:
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);
}
在Controller.php类(系统)中原始文件的第230行
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');
}