Codeigniter AUtoload和Flourish Autoload函数之间的冲突 [英] Conflict between Codeigniter AUtoload and Flourish Autoload functions
问题描述
我正在开发一个网络应用程序,使用Codeigniter( http://codeigniter.com/ )框架加上繁荣图书馆( unframework )( http://flourishlib.com/ )。
I am developing a web application, using the Codeigniter ( http://codeigniter.com/ ) framework plus the Flourish library (unframework) ( http://flourishlib.com/ ).
我简单地把繁荣的文件夹放到我的应用程序,然后我创建了一个繁荣的初始化和配置文件(这些创建Flourish自动加载)。
I simply dropped the flourish folder into my application, then I created a flourish initialization and config files as instructed (these create the Flourish autoload).
这是我的文件夹结构:
--- auxcode\
-------- init .php
-------- config.php
-------- flourish\
- -system\
--- application\
--- public_html\
---auxcode\
--------init.php
--------config.php
--------flourish\
---system\
---application\
---public_html\
init文件只包括配置文件和配置文件内容如下所示:
The init file ONLY includes the config file, and the config file contents shown below:
function __autoload($class_name){
{
// Customize this to your root Flourish directory
$flourish_root = $_SERVER['DOCUMENT_ROOT'] . '/../auxcode/flourish/';
$file = $flourish_root . $class_name . '.php';
if (file_exists($file)) {
include $file;
return;
}
throw new Exception('The class ' . $class_name . ' could not be loaded');
}
文件中添加了以下内容:
In public_html, the index file has been prepended with this:
<?php
include_once($ _ SERVER ['DOCUMENT_ROOT']。 /inc/init.php');
现在,相应的自动加载功能(每个都有自己的功能)是冲突的。该应用程序只有在我注释掉任何框架的自动加载函数(及其依赖项)时才有效。
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . '/../inc/init.php');
Now, the respective autoload functions (as each has its own) are conflicting. The application only works when I comment out the autoload functions (and their dependents) of either framework.
请问如何合并自动加载函数,
Please how can I merge the autoload functions such that I can access both CI and flourish the same way?
或者如果有一个更好的方法在一个应用程序中使用这两个系统?祈祷,告诉。
Or if there is a better method to use both systems in one application? Pray, tell.
感谢。
推荐答案
href =http://codeigniter.com/forums/viewthread/73804/#366081 =nofollow> http://codeigniter.com/forums/viewthread/73804/#366081 和一些位来自我在Twitter上关注的一些CI伙伴的信息(我问em): Eric Barnes , Dan Horrigan , Phil Sturgeon 和 Zack Kitzmiller ,我找到了一个解决方案。如果你是一个CodeIgniter n00b像我一样,你可能会喜欢这些人。
Thanks to http://codeigniter.com/forums/viewthread/73804/#366081 and some bits of information from some CI folk that I follow on twitter (I asked em): Eric Barnes, Dan Horrigan, Phil Sturgeon and Zack Kitzmiller, I found a solution. If you are a CodeIgniter n00b like me, you may like to follow these guys.
我删除了init.php和config.php,然后卡住以下到底我的CI的config.php(我也从一个自定义库mylibrary自动加载)。
I deleted init.php and config.php, then jammed the following into the bottom of my CI's config.php (I am also autoloading from a custom library called mylibrary).
function multi_auto_require($class) {
if(stripos($class, 'CI') === FALSE && stripos($class, 'PEAR') === FALSE) {
foreach (array('flourish', 'mylibrary') as $folder){
if (is_file(APPPATH."../auxengines/{$folder}/{$class}.php")){
include_once APPPATH."../auxengines/{$folder}/{$class}.php";
}
}
}
}
spl_autoload_register('multi_auto_require');
spl_autoload_register('multi_auto_require');
效果非常好。谢谢,人!
Works brilliantly. Thanks, people!
这篇关于Codeigniter AUtoload和Flourish Autoload函数之间的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!