LATCHBUNDLE
Easy integration of Latch in your symfony2 project.
Easy integration of Latch in your symfony2 project.
- 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.
- 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.
# Add LatchBundle in your composer.json:
{
"require": {
"fourcoders/latch-bundle": "dev-master"
}
}
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Fourcoders\Bundle\LatchBundle\FourcodersLatchBundle(),
);
}
// 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 */
}
# app/config/config.yml
fourcoders_latch:
latch_app_id: PdHF10WnSDasSINHHZd0n
latch_app_secret: kH1oqtVlWyWZLKQWIJCAKLodd4XUIgMMLQiwag
latch_redirect: /
# app/config/routing.yml
fourcoders_latch:
resource: "@FourcodersLatchBundle/Resources/config/routing.yml"
prefix: /
$ php app/console doctrine:schema:update --force