Loading phpBB into Laravel code conflicts

I am trying to access some phpBB functions from my Laravel application, this concerns actions such as adding a user when registration occurs on my main site and autologins.

PhpBB is installed under /public/forums , and I updated .htaccess to allow it. I can access and use it just fine.

I have an assistant that was originally built for codeigniter but needs to transfer to the laravel world. I download it as an assistant, putting it in the application, loading it with

 use App\Helpers\phpBBHelper; 

and I get access to the functions as such

  $ph = new phpBBHelper(); $ph->addPhpbb3User('dave','password','dave@dave.com'); 

At the top of my assistant I have this constructor

 public function __construct() { // Set the variables scope global $phpbb_root_path, $phpEx, $cache, $user, $db, $config, $template, $table_prefix; define('IN_PHPBB', TRUE); define('FORUM_ROOT_PATH', 'forum/'); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : FORUM_ROOT_PATH; $phpEx = substr(strrchr(__FILE__, '.'), 1); // Include needed files include($phpbb_root_path . 'common.' . $phpEx); // Initialize phpBB user session $user->session_begin(); $auth->acl($user->data); $user->setup(); // Save user data into $_user variable $this->_user = $user; } 

When I execute the code, I get a 500 server error

 PHP Fatal error: Call to a member function getScriptName() on null in /home/ubuntu/workspace/public/forum/phpbb/session.php on line 50 

which is this line

 $script_name = $request->escape($symfony_request->getScriptName(), true); 

I found a stack overflow message that exactly relates to my problem, but a resolution to this problem has never been posted

conflict between laravel

In this thread, it has been suggested that since both phpBB and Laravel use a composer, it causes a conflict when loading classes. I am not sure if this is true.

But Laravel certainly affects phpBB when I call $user->session_begin(); .

+8
php laravel laravel-5 composer-php phpbb3
source share
4 answers

I would suggest not reinventing the wheel and using an already-encoded extension, such as lara-auth-bridge . Registering is simply inserting the correct rows into the right tables, in particular those not familiar with phpBB3, but you can see the changes in the database after creating a new account.

Edit: you can surround the problematic code in a try {} catch {} if the error is not fatal to the registration itself, so the server will not contain 500.

+5
source share

When two applications had to communicate, I updated them twice. PhpBB is written to update with the extension. You can develop the phpBB extension, which is an API for creating a new user.

Your new extension uses XML-RPC over HTTP for all messages between your laravel application and the forum system. You define a route that receives information about new users, and then you analyze the creation process in phpbb. This method is simpler because you are inside the phpBB / symfony Framework.

In your laravel application, you need to call the API to start messaging.

+2
source share

The error clearly indicates that the symfony_request object is null. Having looked at the source code several times, I found that this variable (and many others) is expected on a global scale.

It seems that you should include phpBB/app.php . He creates most of the necessary objects.

update:

Actually, you include the common file, which does most of the initial setup. Maybe just make global

$symfony_request = $phpbb_container->get('symfony_request');

will work. (I can't check it myself now, just throwing ideas)


(If possible, I would try another library, I do not like these global variables. Nobody does this, which makes tracing and debugging more difficult, as this question shows)

+2
source share

In order to receive a request for a session, you must be sure that the same cookie is used in the PhpBB forum and in your Laravel application:

  • Same domain
  • Same way
  • Same safe flag

Are these settings set?

+2
source share

All Articles