【问题标题】:Codeigniter composer_autoload gives 500 errorCodeigniter composer_autoload 给出 500 错误
【发布时间】:2018-07-10 18:46:14
【问题描述】:

下面是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'

【问题讨论】:

  • A 500 错误是一种通用错误消息,几乎涵盖了脚本可能出错的每一件事。检查您的服务器错误日志以找出确切的错误消息。
  • @aynber:PHP 致命错误:在第 3 行的 /var/www/my_app/public_html/application/controllers/process/method.php 中找不到类“MY_Controller0”

标签: php codeigniter rabbitmq codeigniter-3


【解决方案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;
    }
}

【讨论】:

  • 是的,你是对的,输入路径是有效的,因为它是布尔型的,它等于真,因为它不是空的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-25
  • 2014-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-01
相关资源
最近更新 更多