CodeIgniter 和 PhPBB 3.1.3 集成

CodeIgniter and PhPBB 3.1.3 integration

我基于 CodeIgniter 开发了一个网站,最新版本是 2.2.1,我安装了一个 PhPBB 论坛(版本 3.1.3)。

我想在我的网站上使用论坛的功能(如connection/profile等)。 我看过这个网站:http://www.3cc.org/blog/2010/03/integrating-your-existing-site-into-phpbb3/ 只是为了显示我的伪造。

我的控制器只是第一段的copy/paste

class Forum_test extends CI_Controller{

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
         define('IN_PHPBB', true);
         $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'forum/';
         $phpEx = substr(strrchr(__FILE__, '.'), 1);
         include($phpbb_root_path . 'common.' . $phpEx);
         // Start session management
         $user->session_begin();
         $auth->acl($user->data);
         $user->setup();
    }
}

我的问题是当我尝试使用这段代码时,出现以下错误

Fatal error: Call to a member function header() on a non-object in /var/www/forum/phpbb/session.php on line 224

但是如果我只用

创建一个简单的文档
<?php
define('IN_PHPBB', true);

$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management

$user->session_begin();
$auth->acl($user->data);
$user->setup();
?>

有效(我没有任何错误)

你知道我的代码有什么问题吗?

谢谢。

所以...经过长期研究我找到了解决方案...

https://www.phpbb.com/community/viewtopic.php?f=71&t=2287546

解决方案是在函数索引中添加全局变量

global $request;
global $phpbb_container;
global $phpbb_root_path, $phpEx, $user, $auth, $cache, $db, $config, $template, $table_prefix;
global $request;
global $phpbb_dispatcher;
global $symfony_request;
global $phpbb_filesystem;

我也需要将 phpbb 集成到 codeigniter 基础网站中,遇到了很多问题,终于能够做到。如果您需要它,您可以在 phpbb integration in codeigniter 找到所有代码,它还包含我曾经集成过的 phpbb 版本,但我对此表示怀疑。如果你想改进代码。请在 github.

上打扰我