I'm trying to integrate phpBB 3.1 into my Laravel 5 app. This is so phpBB can handle my user sessions and so I can more easily do things like grab posts and run them through the bbcode parser for rendering on external pages (external to the forum).
I added the phpBB boilerplate to my web route:
Route::get('/', function ()
{
define('IN_PHPBB', true);
$phpbb_root_path = '../../forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
return view('home',
[
'active_tab' => 'home'
]);
});
The error it throws is
Fatal error: Call to a member function getParameter() on null
with the relevant part of the Laravel stack trace being
in file.php line 37
at file->__construct()
at ReflectionClass->newInstanceArgs(array()) in ContainerBuilder.php line 927
at ContainerBuilder->createService(object(Definition), 'cache.driver') in ContainerBuilder.php line 475
at ContainerBuilder->get('cache.driver') in common.php line 131
at include('P:\wamp\www\site\forum\common.php') in web.php line 19
So, in forum/common.php it has
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
That ->get() eventually runs the constructor in forum/phpbb/cache/driver/file.php which has
function __construct($cache_dir = null)
{
global $phpbb_container;
$this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_container->getParameter('core.cache_dir');
$this->filesystem = new \phpbb\filesystem\filesystem();
if (!is_dir($this->cache_dir))
{
@mkdir($this->cache_dir, 0777, true);
}
}
And $phpbb_container is now null in that constructor. It's not null in common.php and looks to get set correctly.
One suggestions in another thread was to put phpbb and laravel in their own folders in the root to avoid autoloading conflicts. I've done this (/site/laravel/ and /site/forum/) but it didn't change the problem.
I also noticed that the error was originally loading some cached files from phpbb's cache. So I cleared the phpbb cache but it now throws the error from the uncached file.
Is Laravel doing something to mess with global variables or is there something deeper going on?