2013-05-19 52 views
7

是的,我想你是想說這個問題是可能的重複,但它不是類似問題的答案不能解決我目前遇到的問題。CodeIgniter - 無法加載請求的類

我自動加載名爲'phpass'的庫時收到以下錯誤,如下所示。

一個錯誤時遇到 無法將請求的類加載:Phpass

代碼以自動加載庫

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

的phpass.php文件駐留在應用程序/庫文件夾,並且該類被聲明爲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); 
    } 
+2

Linux是區分大小寫的,Windows不是,你使用它的類名「phpass」而不是「Phpass」 –

+0

我排除了錯誤是由於文件名,我在Mac上運行,而不是Windows,因此使用MAMP不是WAMP。 –

+0

錯誤告訴我們它尋找「Phpass」不是phpass –

回答

25

我想你的文件名和類名的大小寫問題,根據user guide

  • phppass.phpPhppass.php
  • class phpass應該是class Phpass
+0

是的,輝煌。感謝@lefters! –

+0

這必須解決問題。 –

+0

@max_完全沒問題!我很高興這有幫助! – jleft

相關問題