2017-07-19 57 views
2

我正在使用codeigniter框架。 我想在我的項目上使用redis致命錯誤:未找到類'Predis Client'

要做到這一點,我覺得這個庫:

https://packagist.org/packages/predis/predis 

我與作曲家安裝它。

現在我想使用它:

$client = new Predis\Client(); 

,但我得到這個消息:

Message: Class 'Predis\Client' not found 

我設置這些CONFIGS:

$config['composer_autoload'] = '/vendor/autoload.php'; 
$config['composer_autoload'] = TRUE; 

enter image description here

我OS是勝利dows 7.某處說我應該在我的windows上安裝redis,因爲我使用的是localhost。是嗎?

更新 enter image description here

+0

你裝載了redis庫嗎? –

+0

如何加載這個庫?我剛剛安裝了作曲家。 –

+1

請按照這些說明https://github.com/joelcox/codeigniter-redis –

回答

1

移動composer.jsoncomposer.lockvendor內部應用程序目錄,並留下$config['composer_autoload'] = ''空。從這種方式推薦人們不允許閱讀你的應用程序使用的外部庫/包。另外APPPATH.'vendor'是默認CI位置(由docs)。

如果您由於某種原因希望有composer.json在公開訪問的位置,嘗試這種變化你的現有配置:

$config['composer_autoload'] = FCPATH.'vendor/autoload.php'; 

此外,有你把

use Predis\Client as PredisClient;//for distinctive use of Client word in case of Guzzle, other libs, etc. 

之前控制器類的代碼?之後,你可以使用它作爲

$client = new PredisClient(); 

檢查是否所有這些工程。