php CodeIgniter - 无法加载请求的类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16638279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CodeIgniter - unable to load requested class
提问by max_
Yes, I imagine you are thinking to say that this question is a possible duplicate, however it isn't as the answers for the similar questions do not fix the issue I am currently having.
是的,我想您想说这个问题可能是重复的,但这并不是因为类似问题的答案不能解决我目前遇到的问题。
I'm receiving the following error while autoloading a library named 'phpass' as follows.
我在自动加载名为“phpass”的库时收到以下错误,如下所示。
An Error Was Encountered Unable to load the requested class: Phpass
遇到错误无法加载请求的类:Phpass
Code to autoload the library
自动加载库的代码
$autoload['libraries'] = array('database', 'phpass');
The phpass.php file resides in the application/libraries folder, and the class is declared as class phpassmeaning that the issue cannot be related to capitalisation or the file path as suggested in the majority of other answers I have come across.
phpass.php 文件位于 application/libraries 文件夹中,并且该类被声明为class phpass意味着问题不能与我遇到的大多数其他答案中建议的大小写或文件路径相关。
Please can you tell me what I am missing? It works perfectly in MAMP, however, when uploading to my Linux Ubuntu server (Apache2), it stops working.
请你能告诉我我缺少什么吗?它在 MAMP 中运行良好,但是,当上传到我的 Linux Ubuntu 服务器 (Apache2) 时,它停止工作。
Thanks,
谢谢,
Max.
最大限度。
Edit--- Constructor method as requested by Utku
编辑--- 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);
}
回答by jleft
I think the capitalisation of your file name and class name is the issue, according to the user guide:
根据用户指南,我认为您的文件名和类名的大写是问题所在:
phppass.phpshould bePhppass.phpclass phpassshould beclass Phpass
phppass.php应该Phppass.phpclass phpass应该class Phpass

