TgaForumBundle is a Symfony2 bundle aiming to synchronize Symfony2 with the forum software Vanilla.
Since it has been released, Symfony2 lacks of a complete, well-tested and powerful forum bundle. But why create a new system that already exists in the wild?
Vanilla is a modern, flexible, framework-based forum software providing a complete community platform. The aim of this bundle is to connect it to your Symfony application so you can use Vanilla as an extension of Symfony.
Note: This bundle synchronize Vanilla with Symfony, and not the contrary: Symfony is the master, Vanilla is the slave. It means you should redirect Vanilla subscription and login (with a simple server configuration for instance) to your Symfony one.
Note: The bundle will create a Vanilla user when a user unknown by Vanilla log into Symfony successfully. The created user will have the exact same username in Symfony and Vanilla (that's the matching field).
Install Vanilla
Install Vanilla in your public directory (web
) by downloading it from the official
website and by running it into your browser.
Once fully installed, install the bundle.
Install Symfony bundle
Using Composer : composer require tga/forum-bundle
Add this line to your AppKernel.php
file : new Tga\ForumBundle\TgaForumBundle(),
You have to configure the bundle in your config.yml
file:
tga_forum:
vanilla_path: "%kernel.root_dir%/../web/<your_vanilla_path>
Now, every user connecting/disconnecting throw Symfony should be also connected/disconnected in Vanilla.
The Vanilla kernel is a service (tga_forum.vanilla
) able to boot Vanilla in the current
context of Symfony. Once booted, all the feaures from Vanilla are available in Symfony.
Using the kernel, you have access to two methods : getUserManager
and getSessionManager
,
managing the users and the sessions.
For instance, the AuthenticationSuccessHandler
(connect the users into Vanilla when they
connect in Symfony) uses the Kernel and the managers :
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
$userManager = $this->vanillaKernel->getUserManager();
$sessionManager = $this->vanillaKernel->getSessionManager();
$vanillaUser = $userManager->findByUsername($token->getUsername());
if ($vanillaUser) {
$vanillaUserId = $vanillaUser;
} else {
$vanillaUserId = $userManager->register($token->getUser());
}
$sessionManager->login($vanillaUserId);
$userManager->trackVisit($token->getUser());
return parent::onAuthenticationSuccess($request, $token);
}