2017 © Pedro Peláez
 

symfony-bundle forum-bundle

Symfony TgaForumBundle (bridge to Vanilla Forums)

image

tga/forum-bundle

Symfony TgaForumBundle (bridge to Vanilla Forums)

  • Monday, March 16, 2015
  • by tgalopin
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,438 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

TgaForumBundle

TgaForumBundle is a Symfony2 bundle aiming to synchronize Symfony2 with the forum software Vanilla 2., (*1)

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 PHP?, (*2)

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., (*3)

Installation

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., (*4)

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)., (*5)

Install Vanilla

Install Vanilla in your public directory (web) by downloading it from the official website and by running it into your browser., (*6)

Once fully installed, install the bundle., (*7)

Install the Symfony bundle

1. Download it using Composer, (*8)

composer require tga/forum-bundle, (*9)

2. Register it, (*10)

Edit your AppKernel.php file:, (*11)

``` php <?php, (*12)

class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Tga\ForumBundle\TgaForumBundle(), // ... ); } }, (*13)



**3. Configure it** Edit your `config.yml` file to register where is stored Vanilla: ``` yaml tga_forum: vanilla_dir: %kernel.root_dir%/../web/<your_vanilla_path>

4. Register the security handlers, (*14)

Edit the security.yml configuration file to handle the login/logout successes:, (*15)

``` yaml security: firewalls: main: form_login: success_handler: tga_forum.authentication_success_handler logout: success_handler: tga_forum.logout_success_handler, (*16)



**4. And you are done** Now, every user connecting/disconnecting throw Symfony should be also connected/disconnected in Vanilla. > **Note**: If you have errors with Doctrine not able to update the schema because of Vanilla > tables, you can use the tables filter in the Doctrine configuration: > > ``` yaml > doctrine: > dbal: > schema_filter: ~^(?!GDN_)~ > ``` ### The user transformers The bundle use the concept of UserTransformer to build Vanilla users from Symfony security token. It's an optionnal process you can do if you want to customize the Vanilla users created by the bundle. Declaring your own transformer, you can choose the inserted data. **Use the default transformer or the FOSUserBundle transformer** By default, the bundle provide two transformers: - the default transformer: `tga_forum.default_user_transformer` - the FOSUserBundle transformer for FOS users: `tga_forum.fos_user_transformer` See *Use a transformer* to use them. **Create a custom transformer** User transformers must implements interface `Tga\ForumBundle\Transformer\UserTransformerInterface`. You can use the DefaultUserTransformer to start your own: ``` php <?php namespace Tga\ForumBundle\Transformer; use Symfony\Component\Security\Core\User\UserInterface; use Tga\ForumBundle\Model\VanillaUser; /** * Default transformer: does not do a lot, but enough to work * * @author Titouan Galopin <galopintitouan@gmail.com> */ class DefaultUserTransformer implements UserTransformerInterface { /** * @param UserInterface $user * @return VanillaUser */ public function createVanillaUser(UserInterface $user) { return new VanillaUser($user->getUsername()); } }

The method createVanillaUser() is called by the login success handler to transform a Symfony user in a Vanilla one., (*17)

Use a transformer, (*18)

Declare it as a service and register it in the bundle configuration:, (*19)

``` yaml services: my_user_transformer: class: Acme\UserBundle\Transformer\MyUserTransformer, (*20)

tga_forum: vanilla_dir: %kernel.root_dir%/../web/ user_transformer: my_user_transformer, (*21)


> **Note** : if you don't specify `user_transformer` key, the default transformer will be used. ### How does it work? The Vanilla Kernel 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 : ``` php 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); }

The Versions

16/03 2015

dev-master

9999999-dev https://github.com/tgalopin/TgaForumBundle

Symfony TgaForumBundle (bridge to Vanilla Forums)

  Sources   Download

GNU GPL v2

The Requires

 

bundle symfony forum vanilla

14/01 2015

0.1

0.1.0.0 https://github.com/tgalopin/TgaForumBundle

Symfony TgaForumBundle (bridge to Vanilla Forums)

  Sources   Download

GNU GPL v2

The Requires

 

bundle symfony forum vanilla