Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Integrate the Facebook Platform into your Symfony2 application.

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 DependencyInjection
Octocat-spinner-32 Resources
Octocat-spinner-32 Templating
Octocat-spinner-32 Tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 KrisFacebookBundle.php
Octocat-spinner-32 phpunit.xml.dist


  1. Add this bundle and the Facebook PHP SDK to your project as Git submodules:

      $ git submodule add git:// src/Bundle/Kris/FacebookBundle
      $ git submodule add git:// src/vendor/facebook
  2. Add this bundle to your application's kernel:

      // application/ApplicationKernel.php
      public function registerBundles()
          return array(
              // ...
              new Bundle\Kris\FacebookBundle\KrisFacebookBundle(),
              // ...
  3. Configure the facebook service in your config:

      # application/config/config.yml
        file:   %kernel.root_dir%/../src/vendor/facebook/src/facebook.php
        alias:  facebook
        app_id: 123456879
        secret: s3cr3t
        cookie: true
      # application/config/config.xml

    If you do not include a file value in the config you will have to configure your application to autoload the Facebook class.

Setting up the JavaScript SDK

A templating helper is included for loading the Facebook JavaScript SDK and initializing it with parameters from your service container. To setup the Facebook JavaScript environment, add the following to your layout just after the opening body tag:

    <!-- inside a php template -->
    <?php echo $view['facebook']->initialize(array('xfbml' => true)) ?>
    <!-- inside a twig template -->
    {{ _view.facebook.initialize(['xfbml': true])|raw }}

If you will be adding XFBML markup to your site you must also declare the namespace, perhaps in the opening html tag:

  <html xmlns:fb="">
Something went wrong with that request. Please try again.