Awesome
Facebook Connect for symfony and sfGuard
kdDoctrineGuardFacebookConnectPlugin provides an easy way to sign into a symfony 1 application using a Facebook account. It extends sfDoctrineGuardPlugin.
Installation
-
Install and configure sfDoctrineGuardPlugin
-
Install kdDoctrineGuardFacebookConnectPlugin
# Example using git git submodule add http://github.com/dunglas/kdDoctrineGuardFacebookConnectPlugin.git plugins/kdDoctrineGuardFacebookConnectPlugin
-
Create your Facebook application
-
Enable the plugin in the
config/ProjectConfiguration.class.php
file after sfDoctrineGuardPlugin.class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enablePlugins('sfDoctrinePlugin'); $this->enablePlugins('sfDoctrineGuardPlugin'); $this->enablePlugins('kdDoctrineGuardFacebookConnectPlugin'); } }
-
Rebuild your database and classes
php symfony doctrine:build --all --and-load
-
Edit
app.yml
to match your Facebook application settingsall: facebook: appId: xxx # Your app id secret: yyy # Your app secret cookie: true # Use cookie script_lang: en_US # Facebook UI language
-
Edit
filters.yml
to enable the FacebookConnect filterrendering: ~ security: ~ # Facebook Connect facebook: class: kdDoctrineGuardFacebookConnectFilter # Remember me remember_me: class: sfGuardRememberMeFilter # insert your own filters here cache: ~ execution: ~
-
Enable the kdGuardAuthFacebookConnect module and set is a signin module in
settings.yml
all: .settings: # ... enabled_modules: [default, sfGuardAuth, kdGuardAuthFacebookConnect] login_module: kdGuardAuthFacebookConnect login_action: signin
-
Add the Facebook Login button JavaScript before the body end tag in your app's layout
... <?php include_slot('fb_connect') ?> </body> ...
-
Update your templates to use the route
kd_guard_signin
for signin andkd_guard_signout
for logout instead of the sfDoctrineGuard default routes -
Clear the cache with
php symfony cc
and enjoy!