CodeIgniter and PhPBB 3.1.3 integration


CodeIgniter and PhPBB 3.1.3 integration

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

我想在我的网站上使用论坛的功能(如连接/个人资料等)。我浏览过这个网站:http://www.3cc.org/blog/2010/03/integrating-your-existing-site-into-phpbb3/简单地显示我的伪。

我的控制器只是第一段的复制/粘贴

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的基础网站中,并面临许多问题,最终能够做到这一点。如果你需要它,你可以在codeigniter中找到phpbb集成中的所有代码,它还包含我用来集成的phpbb版本,也有疑问。如果你想改进代码。请在github上向我展示。