我正试图在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年2月1日解决
根据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现在作为include工作,因为我不再使用Session类。
CI具有不同的类命名。所有CI类都以CI_
开头,而Kohana不使用任何前缀*。
我能想到的唯一解决方案是重构Kohana Session类(到处重命名)或使用phpBB库。但两者都不理想。
*)为了澄清,Kohana确实使用了Kohana_
,但它们所有的类都是由没有前缀的类扩展的。