CodeIgniter - unable to load requested class
I think the capitalisation of your file name and class name is the issue, according to the user guide:
-
phppass.php
should bePhppass.php
-
class phpass
should beclass Phpass
Comments
-
max_ about 4 years
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.
An Error Was Encountered Unable to load the requested class: 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 phpass
meaning that the issue cannot be related to capitalisation or the file path as suggested in the majority of other answers I have come across.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.
Thanks,
Max.
Edit--- Constructor method as requested by 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); }
-
Utku Yıldırım almost 11 yearsLinux is case sensitive, windows not, are you use its class name "phpass" not "Phpass"
-
max_ almost 11 yearsI ruled out the error being as a result of the filename, and I'm running on Mac, not windows, hence using MAMP not WAMP.
-
Utku Yıldırım almost 11 yearsError tells us its looking for "Phpass" not phpass
-
max_ almost 11 yearsYes, but it's not possible considering the code I am using. I'm not calling
Phpass
anywhere in my code, onlyphpass
-
Utku Yıldırım almost 11 yearscan you paste first lines of phpass.php file where its contructor visible
-
max_ almost 11 yearsI've updated the question with the constructor.
-
-
max_ almost 11 yearsYes, brilliant. Thanks @lefters!
-
jleft almost 11 yearsNo problem at all @max_! I'm glad this helped!