jackprice / doctrine-encrypt
A package for the safe encryption of Doctrine fields
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jackprice/doctrine-encrypt
Requires
- ext-mcrypt: *
- ext-openssl: *
- doctrine/orm: ^2.5
- paragonie/random_compat: ^1|^2
- symfony/console: ^2
Requires (Dev)
- phpunit/phpunit: ^5.0
This package is not auto-updated.
Last update: 2025-12-31 00:49:41 UTC
README
A package for the safe encryption and decryption of Doctrine fields.
Usage
Register the custom encrypted Doctrine type somewhere in the initialisation of your application.
<?php \Doctrine\DBAL\Types\Type::addType( \DoctrineEncrypt\Types\Encrypted::ENCRYPTED, \DoctrineEncrypt\Types\Encrypted::class );
Set the encryption key.
Important: You are responsible for securing and generating a strong key.
<?php $encryptor = new \DoctrineEncrypt\Encryptors\AES256Encryptor(sha1('Use a very strong key here')); \DoctrineEncrypt\Types\Encrypted::setEncryptor($encryptor);
Use the encrypted type in your entities.
<?php class MyEntity { /** * @ORM\Column(type="encrypted") */ protected $encrypted; }
TODO
- Add more documentation
- Handle unencrypted fields
- Create a CLI to encrypt fields
- Allow key rotation