fulgurio/social-network-bundle
Composer 安装命令:
composer require fulgurio/social-network-bundle
包简介
Symfony FulgurioSocialNetworkBundle
关键字:
README 文档
README
The SocialNetworkBundle adds support to make a social network on your symfony 2 project.
Prerequisites
Translations
If you wish to use default texts provided in this bundle, you have to make sure you have translator enabled in your config.
# app/config/config.yml framework: translator: ~
For more information about translations, check Symfony documentation.
Installation
The bundle uses FOSUser. Configuration of this bundle is also included on this document.
Installation is a quick 3 step process:
- Download FulgurioSocialNetworkBundle
- Configure the Autoloader
- Enable the Bundle
- Configure your application's security.yml
- Configure the FOSUserBundle
- Configure the bundle
- Import FulgurioSocialNetworkBundle routing
- Update your database schema
Step 1: Download FulgurioSocialNetworkBundle
Ultimately, the FulgurioSocialNetworkBundle files should be downloaded to the
vendor/bundles/Fulgurio/SocialNetworkBundle directory.
This can be done in several ways, depending on your preference. The first method is the standard Symfony2 method.
Using the vendors script
Add the following lines in your deps file:
[FOSUserBundle] git=git://github.com/FriendsOfSymfony/FOSUserBundle.git target=bundles/FOS/UserBundle version=1.2.0 [Stof-DoctrineExtensionsBundle] git=http://github.com/stof/StofDoctrineExtensionsBundle.git version=origin/1.0.x target=/bundles/Stof/DoctrineExtensionsBundle [gedmo-doctrine-extensions] git=http://github.com/Atlantic18/DoctrineExtensions.git version=origin/2.2.x [knp-components] git=http://github.com/KnpLabs/knp-components.git version=v1.1 [KnpPaginatorBundle] git=http://github.com/KnpLabs/KnpPaginatorBundle.git target=bundles/Knp/Bundle/PaginatorBundle version=v2.2 [FulgurioSocialNetworkBundle] git=git://github.com/Fulgurio/SocialNetworkBundle.git target=bundles/Fulgurio/SocialNetworkBundle
Now, run the vendors script to download the bundle:
$ php bin/vendors install
Using submodules
If you prefer instead to use git submodules, then run the following:
$ git submodule add git://github.com/FriendsOfSymfony/FOSUserBundle.git vendor/bundles/FOS/UserBundle $ git submodule add git://github.com/stof/StofDoctrineExtensionsBundle.git vendor/bundles/Stof/DoctrineExtensionsBundle $ git submodule add git://github.com/Atlantic18/DoctrineExtensions.git vendor $ git submodule add git://github.com/KnpLabs/knp-components.git vendor $ git submodule add git://github.com/KnpLabs/KnpPaginatorBundle.git vendor/bundles/Knp/Bundle/PaginatorBundle $ git submodule add git://github.com/Fulgurio/SocialNetworkBundle.git vendor/bundles/Fulgurio/SocialNetworkBundle $ git submodule update --init
Step 2: Configure the Autoloader
Add the namespace to your autoloader:
<?php // app/autoload.php $loader->registerNamespaces(array( // ... 'FOS' => __DIR__.'/../vendor/bundles', 'Stof' => __DIR__.'/../vendor/bundles', 'Gedmo' => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib', 'Knp\\Component' => __DIR__.'/../vendor/knp-components/src', 'Knp\\Bundle' => __DIR__.'/../vendor/bundles', 'Fulgurio' => __DIR__.'/../vendor/bundles', ));
Step 3: Enable the bundles
Finally, enable the bundles in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new FOS\UserBundle\FOSUserBundle(), new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(), new Fulgurio\SocialNetworkBundle\FulgurioSocialNetworkBundle(), ); }
Step 4: Configure your application's security.yml
In order for Symfony's security component to use the FOSUserBundle, you must
tell it to do so in the security.yml file. The security.yml file is where the
basic configuration for the security for your application is contained.
Below is a minimal example of the configuration necessary to use the FOSUserBundle in your application:
# app/config/security.yml security: providers: fos_userbundle: id: fos_user.user_manager encoders: FOS\UserBundle\Model\UserInterface: sha512 firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider remember_me: true logout: true anonymous: true remember_me: key: "%secret%" lifetime: 31536000 # 365 days, in seconds path: / domain: ~ access_control: - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/friends/, role: IS_AUTHENTICATED_FULLY } - { path: ^/messenger/, role: IS_AUTHENTICATED_FULLY } - { path: ^/admin/, role: ROLE_ADMIN } role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: ROLE_ADMIN
Under the providers section, you are making the bundle's packaged user provider
service available via the alias fos_userbundle. The id of the bundle's user
provider service is fos_user.user_manager.
Next, take a look at examine the firewalls section. Here we have declared a
firewall named main. By specifying form_login, you have told the Symfony2
framework that any time a request is made to this firewall that leads to the
user needing to authenticate himself, the user will be redirected to a form
where he will be able to enter his credentials. It should come as no surprise
then that you have specified the user provider we declared earlier as the
provider for the firewall to use as part of the authentication process.
Step 5: Configure the FOSUserBundle
Now that you have properly configured your application's security.yml to work
with the FOSUserBundle, the next step is to configure the bundle to work with
the specific needs of your application.
Add the following configuration to your config.yml file according to which type
of datastore you are using.
# app/config/config.yml fos_user: db_driver: orm firewall_name: main user_class: Fulgurio\SocialNetworkBundle\Entity\User registration: form: type: fulgurio_social_network_registration_type resetting: form: type: fulgurio_social_network_resetting_type profile: form: type: fulgurio_social_network_profile_type stof_doctrine_extensions: orm: default: timestampable: true sluggable: true
Step 6: Configure the bundle
Now configure the bundle, just set contact email (it's the "From:" email of bundle sent email)
# app/config/config.yml fulgurio_social_network: contact: admin: email: address: contact@example.com sender_name: Contact avatar: admin: remove: email: address: contact@example.com
Step 7: Import FulgurioSocialNetworkBundle routing
Now that you have activated and configured the bundle, all that is left to do is import the FulgurioSocialNetworkBundle routing files.
By importing the routing files you will have ready made pages for things such as logging in, creating users, etc.
In YAML:
# app/config/routing.yml fos_user_security: resource: "@FulgurioSocialNetworkBundle/Resources/config/routing.yml"
Or if you prefer XML:
<!-- app/config/routing.xml --> <import resource="@FulgurioSocialNetworkBundle/Resources/config/routing.yml"/>
Step 8: Update your database schema
Now that the bundle is configured, the last thing you need to do is update your
database schema because you have added a new entity, the User class which you
created in Step 4.
For ORM run the following command.
$ php app/console doctrine:schema:update --force
Now that you have completed the basic installation and configuration of the FulgurioSocialNetworkBundle, you are ready to learn about more advanced features and usages of the bundle.
fulgurio/social-network-bundle 适用场景与选型建议
fulgurio/social-network-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 207 次下载、GitHub Stars 达 8, 最近一次更新时间为 2015 年 05 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「social network」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fulgurio/social-network-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fulgurio/social-network-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fulgurio/social-network-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
LinkedIn integration for Social
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
PHP SDK for Bands In Town API
Serve Laravel Assets from a Content Delivery Network (CDN)
统计信息
- 总下载量: 207
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL
- 更新时间: 2015-05-03