tga/forum-bundle
最新稳定版本:0.1
Composer 安装命令:
composer require tga/forum-bundle
包简介
Symfony TgaForumBundle (bridge to Vanilla Forums)
README 文档
README
TgaForumBundle is a Symfony2 bundle aiming to synchronize Symfony2 with the forum software Vanilla 2.
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?
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.
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.
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 the Symfony bundle
1. Download it using Composer
composer require tga/forum-bundle
2. Register it
Edit your AppKernel.php file:
<?php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Tga\ForumBundle\TgaForumBundle(), // ... ); } }
3. Configure it
Edit your config.yml file to register where is stored Vanilla:
tga_forum: vanilla_dir: %kernel.root_dir%/../web/<your_vanilla_path>
4. Register the security handlers
Edit the security.yml configuration file to handle the login/logout successes:
security: firewalls: main: form_login: success_handler: tga_forum.authentication_success_handler logout: success_handler: tga_forum.logout_success_handler
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:
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 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.
Use a transformer
Declare it as a service and register it in the bundle configuration:
services: my_user_transformer: class: Acme\UserBundle\Transformer\MyUserTransformer tga_forum: vanilla_dir: %kernel.root_dir%/../web/<your_vanilla_path> user_transformer: my_user_transformer
Note : if you don't specify
user_transformerkey, 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 :
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); }
tga/forum-bundle 适用场景与选型建议
tga/forum-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.47k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 01 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「forum」 「bundle」 「vanilla」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tga/forum-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tga/forum-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tga/forum-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
A Laravel 5 package providing a solid foundation for building discussion forums
A frontend for riari/laravel-forum providing views written with Bootstrap 3
DMS Meetup API Bundle, enables Meetup API clients in services
统计信息
- 总下载量: 1.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GNU
- 更新时间: 2015-01-14