Codeigniter composer_autoload给出500错误

时间:2018-07-10 18:46:14

标签: php codeigniter rabbitmq codeigniter-3

下面是config.php文件:

$config['composer_autoload'] = APPPATH.'vendor/autoload.php';
function __autoload($class){
    if($class == "MY_Controller0"){
        @include_once( APPPATH . 'core/'. $class . '.php' );
    }
}

当我删除__autoload函数时,它工作正常。有了该功能,即可获得HTTP ERROR 500

在供应商中有一个codeigniter-rabbitmq-library。 如何与现有代码一起运行Rabbitmq库?

  

PHP致命错误:在第3行的/var/www/my_app/public_html/application/controllers/process/method.php中找不到类'MY_Controller0'

1 个答案:

答案 0 :(得分:1)

在CodeIgniter 3中,$config['composer_autoload']值是一个布尔值。不需要路径。
__autoload函数已弃用。也许:

spl_autoload_register(function ($class) {
if ($class === 'MY_Controller0') {
    if (file_exists($file = APPPATH . 'core/'. $class . '.php')) {
        include_once $file;
    }
}