如何更正 codeIgniter 插件的 PHP 路径?
我尝试自己将 Rediska(Redis PHP 客户端)安装到我的 codeigniter 应用程序中,但没有成功。当我尝试将其放入 Codeigniter 的插件文件夹时,我会收到大量“没有这样的文件或目录”错误:
严重性:警告
消息: require_once(Rediska/Connection/Exception.php) [function.require-once]:未能 打开流:没有这样的文件或目录
文件名:Rediska/Connection.php
行号:6
有人在我之前成功将 Rediska 安装到 Codeigniter 中吗?
从Rediska安装手册来看,它似乎是一个简单易用的直接安装: http://rediska.geometria-lab.ru/documentation/get-started/
由于现在仅涉及基于路径的错误,我假设应该有一些方便的 PHP 设置,我可以改变以使其一切正常?
谢谢!
I have tried by myself to install Rediska (Redis PHP client) into my codeigniter application, but without any 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 directoryFilename: 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个简单的 include_path 相关问题。换句话说,PHP 无法自动加载您尝试使用的库(在您的情况下为 Rediska)尝试加载的文件。
我假设您已将 Rediska 库目录的内容提取到 Code Igniter 的 system/application/libraries 目录中(以便在库目录中您有 Rediska.php 和 Rediska 目录)。您必须插入以下代码:
...到以下位置之一(由您选择哪一个):
然后,您应该能够使用以下几行(从您的控制器,甚至其他库)加载 rediska:
或者,您可能希望自动加载 Rediska 库,而不是手动加载库。有关更多信息,请参阅 http://codeigniter.com/user_guide/general/autoloader.html信息。
希望有帮助。
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:
...into ONE of following places (it's up to you to choose which one):
Then, you should be able to load rediska using following lines (from your controller, or even some other library):
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.
我没有让 ini_set 解决方案起作用,但是该行的一个变体效果很好:
set_include_path(get_include_path() . PATH_SEPARATOR . APPPATH.'libraries/');
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/');
刚刚注意到 phil Sturgeon 关于插件变得多余的说明......
我目前正在将 Rediska 滚动到 CI 库中,但对于一般用途,您可以使用以下内容包含基于 CI 应用程序路径的文件
将在 system/applications/libraries/rediska/ 中包含 Exception.php
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
Would include the Exception.php in system/applications/libraries/rediska/