【发布时间】:2012-01-09 12:16:23
【问题描述】:
我正在尝试在 Kohana 中实现一个 phpBB 库。
我在我的模块中创建了一个供应商文件夹,并像这样加载库并初始化它:
require_once Kohana::find_file('vendor/phpbb_library', 'phpbb_library');
$phpbb = new Phpbb_library();
但是一旦库开始尝试包含 phpBB 文件:
// Include needed files
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'config.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
然后我收到以下错误:
ErrorException [ Fatal Error ]: Class user contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (Kohana_Session::_read, Kohana_Session::_regenerate, Kohana_Session::_write, ...)
现在包含的文件是phpBB使用的,所以显然我不能只修改它们。
已于 2012 年 1 月 2 日解决
按照Michal M 提出的解决方案,我创建了自己的 Kohana Session 类版本并将它们保存在一个模块中。我必须复制、重命名和编辑的文件是:
/system/classes/session.php
/system/classes/session/cookie.php
/system/classes/session/exception.php
/system/classes/session/native.php
/system/classes/kohana/session.php
/system/classes/kohana/session/cookie.php
/system/classes/kohana/session/exception.php
/system/classes/kohana/session/native.php
在所有文件中,主要编辑涉及将类名 Session 更改为 MySiteSession 和 Kohana_Session 更改为 Kohana_MySite_Session。尽管/system/classes/kohana 文件中变量的一些用法也需要更改名称。
现在要使用会话,我只需调用MySiteSession::instance()。
PHPBB 现在作为一个包含,因为我不再使用 Session 类。
【问题讨论】:
-
错误被触发是因为 phpBB 和 Kohana 都有一个 Session 类。没有解决办法。
-
怎么可能没有解决办法? CodeIgniter 允许它工作:codeigniter.com/wiki/phpBB3_library 我认为 Kohana 是 CodeIgniter 框架的偏移量。
-
你真的成功实现了桥接吗?你能分享一下来源吗?谢谢
-
@zdmytriv 是的,我设法按照 Michal M 的建议去做,并设置了我自己的类来处理我现在使用的会话,而不是默认的 Session 类。这消除了两个系统之间的冲突。
标签: php include kohana kohana-3 abstract