问题描述
我开发了一个基于CodeIgniter的网站,最新版本为2.2.1,我安装了一个PhPBB论坛(版本3.1.3)。
I develop a website site based on CodeIgniter, the latest version 2.2.1 and I installed a PhPBB forum (version 3.1.3).
使用我的网站上的论坛的功能(如连接/配置文件等)。
我看过这个网站:只显示我的伪。
I would like to use the functions of the forum on my web site (like the connection/profile etc.).I've looked on this site : http://www.3cc.org/blog/2010/03/integrating-your-existing-site-into-phpbb3/ to simply display my pseudo.
我的控制器只是第一段的复制/粘贴
My Controller is just a copy/paste of the first paragraph
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();
}
}
我的问题是当我尝试使用此代码,我有以下错误
And my problem is when I try to use this code, I have the following error
Fatal error: Call to a member function header() on a non-object in /var/www/forum/phpbb/session.php on line 224
但是如果我创建一个简单的文档
But if I create a simple document with only
<?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();
?>
它可以工作(我没有任何错误)
It works (I don't have any error)
您对我的代码有什么问题吗?
谢谢。
推荐答案
所以...我在长期研究后找到了解决方案...
So ... I found the solution after long research ...
解决方案是将全局变量添加到函数index
The solution was to add global variables to the function index
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;
这篇关于CodeIgniter和PhPBB 3.1.3集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!