2017 © Pedro Peláez
 

symfony-bundle facebook-authentication-bundle

This bundle helps you to add "Login with facebook" feature to your app

image

lzakrzewski/facebook-authentication-bundle

This bundle helps you to add "Login with facebook" feature to your app

  • Sunday, February 7, 2016
  • by lzakrzewski
  • Repository
  • 0 Watchers
  • 9 Stars
  • 45 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 114 % Grown

The README.md

FacebookAuthenticationBundle

Build Status Latest Stable Version Total Downloads, (*1)

This bundle provides Facebook authentication for your Symfony2 app using the FOSUserBundle. Target: Keep it minimalistic and use existing components from Symfony2 and FOSUserBundle., (*2)

Features

  • Enable login with facebook feature to your app,
  • Add user created from facebook data to your app.

Requirements

    "require": {
        "php": ">=5.4",
        "friendsofsymfony/user-bundle": "~2.0@dev",
        "lzakrzewski/facebook-authentication-adapter": "~1.0"
    }

Supported Facebook API version

  • v2.5

Installation

Step 1: Integrate FOSUserBundle with your app

Read the Documentation for master., (*3)

Step 2: Require the FacebookAuthenticationBundle with composer

composer require lzakrzewski/facebook-authentication-bundle "~1.0"

Step 3: Enable the FacebookAuthenticationBundle

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Lzakrzewski\FacebookAuthenticationBundle\LzakrzewskiFacebookAuthenticationBundle(),
        // ...
    );
}

Step 4: Implement your User class with FacebookUser

<?php
// src/AppBundle/Entity/User.php

namespace AppBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Lzakrzewski\FacebookAuthenticationBundle\Model\FacebookUser;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class User extends BaseUser implements FacebookUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="bigint", nullable=true)
     */
    private $facebookId;

    /** {@inheritdoc} */
    public function getFacebookId()
    {
        return $this->facebookId;
    }

    /** {@inheritdoc} */
    public function setFacebookId($facebookId)
    {
        $this->facebookId = $facebookId;
    }
}

Notice field for store FacebookId should be named facebookId or Annotation FacebookId should be used: FacebookId Annotation., (*4)

Step 5: Configure the config.yml

Minimal configuration:
lzakrzewski_facebook_authentication:
    app_id: 1234
    app_secret: secret

Parameters: app_id and secret are needed to get access token: Access Tokens., (*5)

Example of full configuration:
lzakrzewski_facebook_authentication:
    app_id: 1234
    app_secret: secret
    scope: ["public_profile", "email", "user_birthday"]
    fields: ["name", "email", "birthday"]

Parameters:, (*6)

  • scope An array of permissions: Permissions with Facebook Login,
  • fields By default, not all the fields in a node or edge are returned when you make a query. You can choose the fields (or edges) you want returned with the "fields" query parameter. Choosing Fields.

Notice, (*7)

  • scope Should contain public_profile, email or more,
  • fields Should contain name, email or more.

Step 6: Confgure your routing.yml

facebook_login_path:
    pattern: /facebook/login

Step 7: Enable facebook_listener in your security.yml

# app/config/security.yml
security:
    # ...

    firewalls:
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4

            logout:       true
            anonymous:    true
            # Enable facebook_listener  
            lzakrzewski_facebook: true

    # ...

Step 8: Update your database schema

php app/console doctrine:schema:update --force

Step 9: Setup your facebook app

Documentation, (*8)

Now when route /facebook/login will be requested then procedure of code exchange will be process Code exchange., (*9)

Further documentation

The Versions

07/02 2016

dev-master

9999999-dev

This bundle helps you to add "Login with facebook" feature to your app

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar lzakrzewski

07/02 2016
14/10 2015

1.0.4

1.0.4.0

This bundle helps you to add "Login with facebook" feature to your app

  Sources   Download

MIT

The Requires

 

The Development Requires

by lucaszz111

14/10 2015

1.0.3

1.0.3.0

This bundle helps you to add "Login with facebook" feature to your app

  Sources   Download

MIT

The Requires

 

The Development Requires

by lucaszz111

12/10 2015

1.0.2

1.0.2.0

This bundle helps you to add "Login with facebook" feature to your app

  Sources   Download

MIT

The Requires

 

The Development Requires

by lucaszz111

20/06 2015

0.0.1

0.0.1.0

This bundle helps you to add "Login with facebook" feature to your app

  Sources   Download

MIT

The Requires

 

by lucaszz111

20/06 2015

1.0.1

1.0.1.0

This bundle helps you to add "Login with facebook" feature to your app

  Sources   Download

MIT

The Requires

 

by lucaszz111

20/06 2015

0.1

0.1.0.0

This bundle helps you to add "Login with facebook" feature to your app

  Sources   Download

MIT

The Requires

 

by lucaszz111

20/06 2015

1.0.0

1.0.0.0

This bundle helps you to add "Login with facebook" feature to your app

  Sources   Download

MIT

The Requires

 

by lucaszz111