Zend framework Zend错误:注册表已初始化

Zend framework Zend错误:注册表已初始化,zend-framework,Zend Framework,情况是这样的: -我有一个论坛软件,XenForo供客户在其中嬉戏 -我有一个会员软件aMember,用于处理客户付款和交付数字产品。(均在同一网站上) aMember有一个模板系统,允许您(理想情况下)轻松定制脚本,使其看起来像是网站的一部分 XenForo有一个脚本插件,允许您使用PHP“include”函数使用定制的XenForo页眉和页脚 因此,本质上,我可以使用一个普通的php文件,使用php include调用XenForo页眉和页脚,并使该页面看起来像论坛软件的一部分(几乎像wor

情况是这样的: -我有一个论坛软件,XenForo供客户在其中嬉戏 -我有一个会员软件aMember,用于处理客户付款和交付数字产品。(均在同一网站上)

aMember有一个模板系统,允许您(理想情况下)轻松定制脚本,使其看起来像是网站的一部分

XenForo有一个脚本插件,允许您使用PHP“include”函数使用定制的XenForo页眉和页脚

因此,本质上,我可以使用一个普通的php文件,使用php include调用XenForo页眉和页脚,并使该页面看起来像论坛软件的一部分(几乎像wordpress页眉/页脚)。到目前为止,我提到的所有内容都是在aMember系统之外测试和工作的,因此我目前有一个index.php文件,它使用include调用XenForo页眉和页脚,效果非常好

这就是问题所在,我试图在aMember模板系统中使用PHP include脚本。我让它大部分工作正常,但随后在生成有趣的一批代码时抛出以下错误:

Error: Registry is already initialized
Exception Zend_Exception
Zend_Registry::setClassName [ /home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php : 244 ]
XenForo_Application::initialize [ /home/content/p/p/o/ppowers/html/forum/library/Dark/Kotomi/KotomiHeader.php : 5 ]
include_once [ /home/content/p/p/o/ppowers/html/header.php : 6 ]
include_once [ library/Am/View.php : 419 ]
Am_View->printLayoutHead [ application/default/themes/sample/layout.phtml : 8 ]
include [ library/Am/View.php : 352 ]
Am_View->_run [ library/Zend/View/Abstract.php : 888 ]
Zend_View_Abstract->render [ library/Am/View.php : 326 ]
Am_View->display [ application/default/controllers/IndexController.php : 7 ]
IndexController->indexAction [ library/Am/Controller.php : 139 ]
Am_Controller->_runAction [ library/Am/Controller.php : 116 ]
Am_Controller->dispatch [ library/Zend/Controller/Dispatcher/Standard.php : 295 ]
Zend_Controller_Dispatcher_Standard->dispatch [ library/Zend/Controller/Front.php : 954 ]
Zend_Controller_Front->dispatch [ library/Am/App.php : 1372 ]
Am_App->run [ index.php : 41 ]
据我所知,加上我有限的编程知识,aMember和XenForo似乎在为谁可以使用Zend注册表而争吵

有没有什么方法可以让他们在不雇佣全职程序员的情况下一起玩得很好?非常感谢

对评论的回应:

add注释没有足够的字符,因此下面是一些代码

据我所知,XenForo将其作为主要功能使用……好吧……一切,这里是Application.php的开始,它是XenForo源代码的一部分。这个文件有1000多行,所有这些都构成了类,开始在顶部。。。这似乎是唯一一个使用Zend_注册表的文件,它不是Zend源本身的一部分

class XenForo_Application extends Zend_Registry
{
const URL_ID_DELIMITER = '.';
public static $version = '1.1.0';
public static $versionId = 1010070; // abbccde = a.b.c d (alpha: 1, beta: 3, RC: 5, stable: 7, PL: 9) e
public static $jsVersion = '';
public static $jQueryVersion = '1.5.2';
protected $_configDir = '.';
protected $_rootDir = '.';
protected $_initialized = false;
protected $_lazyLoaders = array();
protected static $_handlePhpError = true;
protected static $_debug;
protected static $_randomData = '';
protected static $_classCache = array();
public static $time = 0;
public static $host = 'localhost';
aMember在多个文件中使用它,以下是一些示例:

这是在form.php中

public function findRuleMessage(HTML_QuickForm2_Rule $rule, HTML_QuickForm2_Node $el)
    {
        $strings = array(
            'rule.required' => ___('This is a required field'),
        );
        $type = lcfirst(preg_replace('/^.+rule_/i', '', get_class($rule)));
            $tr = Zend_Registry::get('Zend_Translate');
        $fuzzy = sprintf('rule.%s', $type);
        if (array_key_exists($fuzzy, $strings))
            return $strings[$fuzzy];
    }
这是app.php的内部

function amDate($string) {
    if ($string == null) return '';
    return date(Zend_Registry::get('Am_Locale')->getDateFormat(), amstrtotime($string));
}
function amDatetime($string) {
    if ($string == null) return '';
    return date(Zend_Registry::get('Am_Locale')->getDateTimeFormat(), amstrtotime($string));
}
function amTime($string) {
    if ($string == null) return '';
    return date(Zend_Registry::get('Am_Locale')->getTimeFormat(), amstrtotime($string));
}
好吧,我最好不要再发源代码了,否则他们会让黑衣人跟着我

看起来在一个月内编程可能会更容易,但这很快看起来像是一项无法克服的任务,特别是在我(缺乏)技能水平的情况下

其他信息:

public static function initialize($configDir = '.', $rootDir = '.', $loadDefaultData = true)
{
(244)self::setClassName(__CLASS__);
self::getInstance()->beginApplication($configDir, $rootDir, $loadDefaultData);
}
注释掉第244行产生以下错误:

Fatal error: Call to undefined method Zend_Registry::beginApplication() in /home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php on line 245
将您建议的代码添加到aMember index.php文件中会产生以下错误:

Fatal error: Class 'XenForo_Application' not found in /home/content/p/p/o/ppowers/html/amember/index.php on line 40

/home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php的在线
244
是什么?如果只是
Zend_Registry
,这是默认的类名,如果您不怕修改源代码,只需在
244
行注释掉调用即可。但不建议这样做,因为如果您希望在将来更新XenForo,您将遇到问题

检查在
244
行上传递给
setClassName()
的内容是否可以以某种方式进行配置。再粘贴一些代码。得到更多的答案

使现代化 使用XenForo可能需要大量的编码,因此我建议采用一种完全不同的方法。由于aMemeber似乎使用香草
Zend_注册表
,您可以尝试确保
XenForo
的扩展版本的
Zend_注册表
首先实例化。在
index.php
(可能位于
public
目录)中,找到带有
$application->bootstrap()的行或类似代码,以及前的此行添加如下内容:

XenForo_Application::setClassName("XenForo_Application");
并注释掉
/home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php的
244


如果这样做有效,请记住对更改进行评论,交叉引用两个修改过的文件。

我使用Zend framework v1.5构建我的网站:(**)| 使用xenforo的论坛:(*)

在主页(**)中,我是身份验证用户Xenforo 我的编码:

define('XF_ROOT', '/home/www/lighttpd/my_web/forum'); // set this (absolute path)!
define('STARTTIME', microtime(true) );
define('SESSION_BYPASS', false); // if true: logged in user info and sessions are not needed
require_once(XF_ROOT . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT . '/library');
XenForo_Application::initialize(XF_ROOT . '/library', XF_ROOT);
XenForo_Application::set('page_start_time', STARTTIME );
XenForo_Application::setDebugMode(false);

if (!SESSION_BYPASS)
{

$dependencies = new XenForo_Dependencies_Public();
$dependencies->preLoadData();
$session =  XenForo_Session::startPublicSession(new Zend_Controller_Request_Http);
    XenForo_Visitor::setup($session->get('user_id'));

    $visitor = XenForo_Visitor::getInstance();    

    if ($visitor->getUserId())
    {
        $userModel = XenForo_Model::create('XenForo_Model_User');
        $userinfo = $userModel->getFullUserById($visitor->getUserId());        
    }

}
错误:注册表已初始化


您能告诉我如何修复吗?

您如何使用Zend_注册表?你能粘贴一些代码吗?根据我(有限的)研究,zend_注册表保存两个软件的变量似乎没有问题。当每个脚本都想使用自己的zend_注册表时,冲突似乎就出现了,但他们必须共享一个。如果这是真的,那么问题就变成了如何让它们都把变量放到同一个Zend_注册表中。让其中一个初始化,另一个只是将其内容放入同一个注册表。下面是第244行的类:(242)公共静态函数初始化($configDir='.',$rootDir='.',$loadDefaultData=true)(243){(244)self::setClassName(class);(245)self::getInstance()->beginApplication($configDir,$rootDir,$loadDefaultData);(246)})您将如何配置它,使其不会抛出错误?顺便说一句,非常感谢您的帮助。将代码粘贴到您的原始帖子和更新中会更有意义,格式设置将使其更易于阅读。您需要进行更多的调试。首先,常量
的计算结果是什么?它是在哪里定义的?通过查看代码,它似乎从该类中提取了大量主要函数,如调用要查看的线程等。此外,我还将代码添加到了顶部。。。。我想知道我是否可以在一个或两个脚本中添加一个“if/then”语句,以防止双重初始化注册表。我不关心升级问题,我只是想让这些东西发挥作用……我尝试了你的两个建议,并在上面公布了结果。非常感谢您抽出时间!这是一个模块化的ZF应用程序吗?你能发布目录结构吗?是否有多个入口点(
index.php
)?第二个错误是找不到类的简单情况,您应该为它安装一个自动加载器,或者只是
r