namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
// importing @Encrypted annotation
use Ambta\DoctrineEncryptBundle\Configuration\Encrypted;
/**
* @ORM\Entity
* @ORM\Table(name="user")
*/
class User {
..
/**
* @ORM\Column(type="string", name="email")
* @Encrypted
* @var int
*/
private $email;
..
}
It is as simple as that, the field will now be encrypted the first time the users entity gets edited. We keep an prefix to check if data is encrypted or not so, unencrypted data will still work even if the field is encrypted.
There are some console commands that can help you encrypt your existing database or change encryption methods. Read more about the database encryption commands provided with this bundle.