Fork me on GitHub

LATCHBUNDLE

Easy integration of Latch in your symfony2 project.

Interested in this bundle?

What must your users do?

- Download the latch app in Apple store or Google market.
- Create a code to synchronize with the page.
- Insert the code once registered.
- Once registered the user will have control of the login with their smartphone.

What must you do?

- Register as a developer in Latch page.
- Create an app for the website.
- Install LatchBundle with the following instructions.
- If you want more information about Latch you can visit the following link.

### Step 1: Download LatchBundle using composer
					
					# Add LatchBundle in your composer.json:
					{
					    "require": {
					        "fourcoders/latch-bundle": "dev-master"
					    }
					}
					
					
### Step 2: Enable the bundle
					
					// app/AppKernel.php
					public function registerBundles()
					{
					    $bundles = array(
					        // ...
					        new Fourcoders\Bundle\LatchBundle\FourcodersLatchBundle(),
					    );
					}
					
					
### Step 3: Update your User class with your provider user class ( FosUserBundle class 100% compatible )
					
					// src/Acme/UserBundle/Entity/User.php
					namespace Acme\UserBundle\Entity;

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

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

					    /* Start of the new field */

					    /**
					     * @var string $latch
					     *
					     * @ORM\Column(name="latch", type="string", length=255, nullable=true)
					     */
					    private $latch;    

					    /**
					     * Set latch
					     *
					     * @param string $latch
					     */
					    public function setLatch($latch)
					    {
					        $this->latch = $latch;
					    }

					    /**
					     * Get latch
					     *
					     * @return string 
					     */
					    public function getlatch()
					    {
					        return $this->latch;
					    }   

					    /* End of the new field */ 

					    public function __construct()
					    {
					        parent::__construct();
					        // your own logic
					    }
					}
					
					
					
					// src/Acme/AccountBundle/Entity/User.php
					namespace Acme\AccountBundle\Entity;

					use Doctrine\ORM\Mapping as ORM;
					use Symfony\Component\Validator\Constraints as Assert;
					use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

					/**
					 * @ORM\Entity
					 * @UniqueEntity(fields="email", message="Email already taken")
					 */
					class User
					{
					    /**
					     * @ORM\Id
					     * @ORM\Column(type="integer")
					     * @ORM\GeneratedValue(strategy="AUTO")
					     */
					    protected $id;

					    /**
					     * @ORM\Column(type="string", length=255)
					     * @Assert\NotBlank()
					     * @Assert\Email()
					     */
					    protected $email;

					    /**
					     * @ORM\Column(type="string", length=255)
					     * @Assert\NotBlank()
					     * @Assert\Length(max = 4096)
					     */
					    protected $plainPassword;

					    public function getId()
					    {
					        return $this->id;
					    }

					    public function getEmail()
					    {
					        return $this->email;
					    }

					    public function setEmail($email)
					    {
					        $this->email = $email;
					    }

					    public function getPlainPassword()
					    {
					        return $this->plainPassword;
					    }

					    public function setPlainPassword($password)
					    {
					        $this->plainPassword = $password;
					    }

					    /* Start of the new field */

					    /**
					     * @ORM\Column(name="latch", type="string", length=255, nullable=true)
					     */
					    private $latch;    

					    public function setLatch($latch)
					    {
					        $this->latch = $latch;
					    }

					    public function getlatch()
					    {
					        return $this->latch;
					    }   

					    /* End of the new field */ 

					}
					
					
### Step 4: Configure the LatchBundle
					
					# app/config/config.yml
					fourcoders_latch:
					    latch_app_id: PdHF10WnSDasSINHHZd0n
					    latch_app_secret: kH1oqtVlWyWZLKQWIJCAKLodd4XUIgMMLQiwag
					    latch_redirect: / 
					
					
### Step 5: Import LatchBundle routing files
					
					# app/config/routing.yml
					fourcoders_latch:
					    resource: "@FourcodersLatchBundle/Resources/config/routing.yml"
					    prefix:   /
					
					
### Step 6: Update your database schema
					
					$ php app/console doctrine:schema:update --force
					
					

Want to try it?