I have tried by myself to install Rediska (Redis PHP client) into my codeigniter application, but without a开发者_开发问答ny success. I'll get insane amounts of "No such file or directory"-errors when trying to put it into the plugins folder of Codeigniter:
Severity: Warning
Message: require_once(Rediska/Connection/Exception.php) [function.require-once]: failed to open stream: No such file or directory
Filename: Rediska/Connection.php
Line Number: 6
Have anyone succeeded to install Rediska into Codeigniter before me?
From looking at the Rediska install manual, It appears to be a simple and easy drop-in installation: http://rediska.geometria-lab.ru/documentation/get-started/
Since it's only about path-based errors right now, I'll assume that there's should be some handy PHP setting that I can change to make it all work?
Thanks!
It's a simple include_path-related problem. In other words, PHP is unable to automatically load files that library you are trying to use (in your case Rediska) is trying to load.
I have assumed that you have extracted contents of Rediska library directory into system/application/libraries directory of Code Igniter (so that in libraries dir you have Rediska.php and Rediska directory). You will have to insert following code:
ini_set('include_path', ini_get('include_path').';'.APPPATH.'libraries/');
...into ONE of following places (it's up to you to choose which one):
- modify main index.php file, before call to require_once function at the very bottom of file
- into (every) controller where you want to use Rediska
- modify Rediska.php file, and add this line to the very top of file (first line after
Then, you should be able to load rediska using following lines (from your controller, or even some other library):
$this->load->library('rediska');
$rediska = new Rediska();
Alternatively, instead of manually loading library, you might want to auto-load Rediska library. See http://codeigniter.com/user_guide/general/autoloader.html for more info.
Hope it helps.
I didn't get the ini_set solution to work, but a variant of that line works great: set_include_path(get_include_path() . PATH_SEPARATOR . APPPATH.'libraries/');
Just noticed the note from phil Sturgeon about plugins being made redundant.....
I'm working on rolling Rediska into a CI library at the moment, but for general use you can using the following to include files based on the CI application path
include(APPPATH.'libraries/rediska/Exception.php');
Would include the Exception.php in system/applications/libraries/rediska/
精彩评论