sopinet / userbundle
简单集成示例,为 Symfony2 的 fosuser+hwi_oauth+sonatauser
dev-master
2015-04-10 07:36 UTC
Requires
- php: >=5.3.3
- friendsofsymfony/user-bundle: 1.3.*
This package is not auto-updated.
Last update: 2024-09-14 15:16:27 UTC
README
简单集成
hwi_oauth: https://github.com/hwi/HWIOAuthBundle
fosub: https://github.com/FriendsOfSymfony/FOSUserBundle
可选(sonatauser & sonataadmin): https://github.com/sonata-project/SonataUserBundle
这是什么?
此包集成 fosub + hwi_oauth,默认选项和配置仅用于工作。您可以将其用作文档、指南或直接用于您的网站。
安装
从 composer,添加
{ "require": { "sopinet/userbundle": "dev-master" } }
将包添加到 AppKernel(可能还需要添加 FOSUB 和 SonataUserBundle)
new Sopinet\UserBundle\SopinetUserBundle(),
配置
- 默认添加配置 / 安全文件
imports - { resource: "@SopinetUserBundle/Resources/config/config.yml" }
如果您想为管理员和用户使用相同的登录页面,则必须导入此文件
imports - { resource: "@SopinetUserBundle/Resources/config/same_login_config.yml" }
- 添加您的 id 和 secret 参数
parameters: sopinet_user_facebook_id: "YOURID-FACEBOOK" sopinet_user_facebook_secret: "YOURSECRET-FACEBOOK" sopinet_user_google_id: "YOURID-GOOGLE" sopinet_user_google_secret: "YOURSECRET-GOOGLE"
- 它与 SonataUserBundle 一起工作,覆盖了 app 中的用户类,因此,您必须配置 FOSUB+SonataUser 的集成
fos_user: db_driver: orm firewall_name: main user_class: Application\Sonata\UserBundle\Entity\User
- 在您的 Application\Sonata\UserBundle\Entity\User 中必须有一个字段 ProfilePicture
/** @ORM\Column(name="profilepicture", type="string", length=500, nullable=true) */ protected $profilepicture; /** * Set profilepicture * * @param string $profilepicture * @return User */ public function setProfilePicture($profilepicture) { $this->profilepicture = $profilepicture; return $this; } /** * Get profilepicture * * @return string */ public function getProfilePicture() { return $this->profilepicture; }
并且必须在 User.orm.xml 中定义
<field name="profilepicture" column="profilepicture" type="string" length="500" nullable="true"></field>
使用方法
<a href="{{ hwi_oauth_login_url('google') }}">Connect with Google</a> <a href="{{ hwi_oauth_login_url('facebook') }}">Connect with Facebook</a>