2

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)

Do you have any idea of what is wrong with my code ?

Thank you.

  • I think you're problem lies here `parent::__construct();` what is the parents constructor? – Daan Feb 18 '15 at 14:43
  • This is only the constructor of the CI_Controller class which is the basic controller of CodeIgniter. Even if I remove it, it doesn't work – Mathieu Dauré Feb 18 '15 at 14:55

2 Answers2

4

So ... I found the solution after long research ...

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

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;
0

I have also needed to integrate phpbb into codeigniter base website and face many problems and finally able to do it. If you need it you can find all code at phpbb integration in codeigniter it also contains phpbb version which I have used to integrate as well as doubtful. If you want to improvement in the code. Please frok me on github.

Gaurav Bhatra
  • 207
  • 2
  • 7
  • Did you use MVC structure? I saw that you used CodeIgniter, but there is no any MVC circumstantial evidence? Am I wrong? – Hasan Apr 19 '16 at 00:15
  • Codeigniter is MVC based and ofcoures i have use MVC structure . i have create a library for comunicate between PHPBB and codeigniter and this libaray bulid in ci using codeiniter . – Gaurav Bhatra Apr 21 '16 at 06:24
  • Can you give some info on github that could help to integrate it in a already built codeigniter website – Heemanshu Bhalla Jan 17 '19 at 06:32
  • As there may be lots of files needs changes for a already built in website so a small exlanation for files that needs change is good to have – Heemanshu Bhalla Jan 17 '19 at 06:46