dwgebler/encrypted-fields-bundle
Pros:
#[EncryptedField]) integrates seamlessly with existing entity structures, reducing cognitive load for developers.credit_card_number, ssn) without over-encrypting non-sensitive data, optimizing performance and storage.prePersist, preUpdate, postLoad), abstracting cryptographic complexity from business logic.encryption_key table provides a centralized repository for keys, aiding compliance audits (e.g., GDPR Article 32).Cons:
encryption_key table, adding complexity to migrations and database backups. Schema changes may conflict with existing CI/CD pipelines.make:migration).laravel-doctrine/orm) and adapting Symfony-specific components (e.g., console commands, config files). Not recommended unless Doctrine is already in use.pgcrypto could offer better throughput).ENCRYPTED_FIELDS_KEY) grants access to all per-record keys. Mitigation: Use a secrets manager (e.g., AWS Secrets Manager) and restrict access via IAM policies.rotate-key command decrypts/re-encrypts all data, which may be impractical for large datasets. Plan for offline backups or incremental rotation strategies.encryption_key table requires a migration, which may cause downtime in production. Use blue-green deployments or zero-downtime migration tools (e.g., Laravel’s migrate:refresh).composer.json for supported versions.10x production load.encrypt()) or database-native encryption (e.g., PostgreSQL TDE) be more suitable?spatie/laravel-encryption) with broader adoption?Symfony (Primary Fit):
composer.json)..env (e.g., ENCRYPTED_FIELDS_KEY=%env(ENCRYPTED_FIELDS_KEY)%).gebler_encrypted_fields.yaml with cipher and key paths.make:migration with Symfony’s make:entity or doctrine:migrations:generate.php bin/console gebler:encryption:rotate-key).Laravel (Partial Fit):
laravel-doctrine/orm).symfony/console, symfony/dependency-injection)..env and a service provider.// app/Console/Commands/RotateEncryptionKey.php
use Gebler\EncryptedFieldsBundle\Command\RotateKeyCommand;
use Symfony\Component\Console\Application;
class RotateEncryptionKey extends Command {
protected $signature = 'gebler:rotate-key {--generate-new-key} {--database-key=} {--database-key-file=}';
public function handle() {
$app = new Application();
$app->add(new RotateKeyCommand());
$app->run(new ArrayInput($this->option('generate-new-key') ? ['command' => 'gebler:encryption:rotate-key', '--generate-new-key' => true] : []));
}
}
spatie/laravel-encryption).Database Layer:
pgcrypto for bulk operations).How can I help you explore Laravel packages today?