dayploy/doctrine-extensions-bundle
Strengths:
ssn, credit_card_number) while leaving non-sensitive data unencrypted, optimizing performance and storage.Weaknesses:
BINARY columns, which may conflict with existing migrations or database constraints.Laravel Compatibility:
encrypt()/decrypt() or packages like spatie/laravel-encryption may offer simpler integration paths for non-Doctrine projects.Database Impact:
BINARY columns for nonce and encrypted values, which may necessitate downtime or careful migration strategies.save()/find() operation could degrade throughput, particularly under high load.BINARY columns to existing tables may require complex migrations or downtime.config or external key management systems (e.g., AWS KMS, HashiCorp Vault) for secure key storage and rotation.encrypt()/decrypt() or packages like spatie/laravel-encryption been evaluated for suitability?// Custom trait for Eloquent models using Doctrine DBAL
trait UsesDoctrineEncryption {
protected $encryptionManager;
public function __construct() {
$this->encryptionManager = new \Dayploy\DoctrineExtensionsBundle\EncryptionManager(
config('doctrine.encryption_key')
);
}
public function getEncryptedAttribute($value) {
return $this->encryptionManager->decrypt($value);
}
public function setEncryptedAttribute($value) {
$this->attributes['encrypted_' . $this->getKeyName()] = $this->encryptionManager->encrypt($value);
}
}
doctrine/dbal (≥2.13) or doctrine/orm (≥2.10) for event listeners.gedmo/doctrine-extensions) to prevent event listener collisions.ssn, credit_card_number, api_token).BINARY columns (e.g., MySQL, PostgreSQL, SQLite).BINARY columns for nonce and encrypted values using Laravel migrations:
Schema::table('users', function (Blueprint $table) {
$table->binary('ssn_nonce')->nullable()->after('ssn');
$table->binary('ssn_encrypted')->nullable()->after('ssn_nonce');
$table->dropColumn('ssn'); // Optional: Drop plaintext column post-migration
});
Cryptable logic.prePersist and preUpdate to handle encryption/decryption.class User extends Model {
use UsesDoctrineEncryption;
#[Cryptable(
nonceProperty: 'ssn_nonce',
encryptedProperty: 'ssn_encrypted',
)]
protected ?string $ssn;
}
How can I help you explore Laravel packages today?