sfCacophonyPlugin - 1.0.1

An alternative to sfMelodyPlugin

You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Dependencies Releases Changelog Contribute
Show source


This plugin implements the OAuth functionality for Symfony 1.4 using PECL OAuth extension.

What's OAuth? Please go to links below for best explanation I've ever seen so far.

  • http://developer.yahoo.com/oauth/guide/about.html
  • http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html


  • PHP 5.3.2+
  • Pecl OAuth extension
    • http://uk3.php.net/manual/en/book.oauth.php
    • http://pecl.php.net/package/oauth
  • sfDoctrineGuardPlugin - for now it doesn't work with Propel

For now it supports OAuth 1.0 providers. So for it has been tested with:

  • Vimeo
  • Twitter
  • Facebook

A Sample application

Please go to https://github.com/nixilla/Cacophony and download the Cacophony app. It uses sfCacophonyPlugin. It's a good example of how to use this plugin.

New application example


  1. mkdir cacophony
  2. cd cacophony/
  3. mkdir -p lib/vendor
  4. cd lib/vendor/
  5. svn export http://svn.symfony-project.com/tags/RELEASE_1_4_14 symfony
  6. cd ../..
  7. php lib/vendor/symfony/data/bin/symfony generate:project cacophony
  8. cd plugins/
  9. svn export http://svn.symfony-project.com/plugins/sfDoctrineGuardPlugin/trunk/ sfDoctrineGuardPlugin
  10. svn export https://svn.github.com/nixilla/sfCacophonyPlugin.git sfCacophonyPlugin
  11. cd ../
  12. vim config/databases.yml
  13. vim config/ProjectConfiguration.class.php
  14. vim config/doctrine/schema.yml
  15. ./symfony doctrine:build --all
  16. ./symfony generate:app frontend
  17. vim web/frontend_dev.php
  18. vim apps/frontend/config/app.yml
  19. vim apps/frontend/config/settings.yml
  20. vim apps/frontend/config/filters.yml
  21. vim apps/frontend/lib/myUser.class.php


Lines 1 to 11 - we're setting up standard symfony application called cacophony with 2 plugins.

Line 12 - configure your database connection settings

Line 13 - enable 2 new plugins


Line 14 - modify sfGuardUser model to accept null for emails, as you won't get emails from some OAuth providers (optional)

      type: string(255)
      notnull: false
      unique: true

Line 15 - build models forms and filters

Line 16 - create frontend app

Line 17 - remove security check from front controller (optional)

Line 18 - add your consumer_key and consumer secret

          consumer_key: YOUR_KEY
          consumer_secret: YOUR_SECRET
          consumer_key: YOUR_ANOTHER_KEY
          consumer_secret: YOUR_ANOTHER_SECRET

Line 19 - enable modules and add sfGuard config

enabled_modules:        [default, sfGuardAuth, sfGuardRegister, sfCacophonyConsumer]

login_module:           sfGuardAuth
login_action:           signin

secure_module:          sfGuardAuth
secure_action:          secure

Line 20 - add filter

rendering: ~
security:  ~

// insert your own filters here
  class: sfCacophonyFilter

cache:     ~
execution: ~

Line 21 - change base class for myUser to sfGuardSecurityUser

class myUser extends sfGuardSecurityUser

Then ./symfony cc and you're good to go

Navigate to http://your.url/frontend_dev.php/oauth/connect/(vimeo|twitter)

Accept your app on your provider's page

and check your database (sf_guard_user and token tables)

For more information please check out the wiki on Github.