Codeigniter在"core"文件夹中查找库

Jam*_*han 4 php codeigniter

我使用ion_auth创建了这个Facebook应用程序.在某些浏览器中,当您授权应用程序时,它不会将用户登录到我的服务器上.

我检查了日志文件,发现了这个

ERROR - 2013-06-10 00:00:01 --> Severity: Warning  --> include_once(application/core/MY_Ion_auth.php): failed to open stream: No such file or directory /var/www/html/application/config/production/config.php 378
ERROR - 2013-06-10 00:00:01 --> Severity: Warning  --> include_once(): Failed opening 'application/core/MY_Ion_auth.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') /var/www/html/application/config/production/config.php 378
Run Code Online (Sandbox Code Playgroud)

现在config.php第378行就像

function __autoload($class)
{
    if (strpos($class, 'CI_') !== 0) {
        @include_once(APPPATH . 'core/' . $class . EXT);
    }
}
Run Code Online (Sandbox Code Playgroud)

ion_auth和go2都是自动加载的库......它们实际上位于库文件夹中.

有任何想法吗?

Ade*_*Ade 5

该库加载错误与旧版的__autoload方法(它允许你自动加载自定义的基本控制器从内application/core).config.php是此方法的正确/推荐位置.

旧版本的副作用是CI尝试在核心目录中查找您加载的任何自定义库.

解决方案是使用新版本的自动加载方法,即:

function __autoload($class)
{
    if (strpos($class, 'CI_') !== 0)
    {
        if (file_exists($file = APPPATH . 'core/' . $class . EXT))
        {
            include $file;
        }

        elseif (file_exists($file = APPPATH . 'libraries/' . $class . EXT))
        {
            include $file;
        }
    }
} 
Run Code Online (Sandbox Code Playgroud)