CodeIgniter-无法加载请求的类

问题描述 投票:8回答:1

是的,我想您正在想说的是,这个问题可能是重复的,但是并非如此,因为类似问题的答案不能解决我当前遇到的问题。

我按如下所示自动加载名为“ phpass”的库时收到以下错误。

遇到错误无法加载请求的类:Phpass

自动加载库的代码

$autoload['libraries'] = array('database', 'phpass');

phpass.php文件位于application / libraries文件夹中,并且该类声明为class phpass,这意味着该问题不能与大写字母或文件路径相关,正如我遇到的大多数其他答案中所建议的那样。

[请您告诉我我在想什么吗?它可以在MAMP中完美运行,但是,当上传到我的Linux Ubuntu服务器(Apache2)时,它将停止工作。

谢谢,

最大

编辑-Utku要求的构造方法

class phpass {

    protected $PasswordHash;

    // default values if config was not found
    protected $iteration_count_log2 = 8;
    protected $portable_hashes = FALSE;

    /**
     * Construct with configuration array
     * 
     * @param array $config
     */
    public function __construct($config = array()) {
        // check if the original phpass file exists
        if (!file_exists($path = dirname(__FILE__) . '/../vendor/PasswordHash.php')) {
            show_error('The phpass class file was not found.');
        }

        include ($path);

        if (!empty($config)) {
            $this->initialize($config);
        }

        // create phpass object
        $this->PasswordHash = new PasswordHash($this->iteration_count_log2, $this->portable_hashes);
    }

是的,我想您可能想说的是,这个问题可能是重复的,但是并非如此,因为类似问题的答案不能解决我当前遇到的问题。我正在接收...

php codeigniter autoload
1个回答
31
投票

根据user guide,我认为您的文件名和类名的大小写是问题所在]]

  • [phppass.php应该是Phppass.php
© www.soinside.com 2019 - 2024. All rights reserved.