dongqianzhan8325 2010-09-29 15:37
浏览 23
已采纳

Codeigniter AUtoload和Flourish Autoload功能之间的冲突

I am developing a web application, using the Codeigniter ( http://codeigniter.com/ ) framework plus the Flourish library (unframework) ( http://flourishlib.com/ ).

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).

This is my folder structure:

---auxcode\
--------init.php
--------config.php
--------flourish\
---system\
---application\
---public_html\

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');

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.

Thanks.

  • 写回答

3条回答 默认 最新

  • dousao2186 2010-10-04 09:55
    关注

    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.

    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');

    Works brilliantly. Thanks, people!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大