- Does austinheap/laravel-database-encryption work with Laravel 10.x or PHP 8.2+?
- No, this package was last updated in 2019 and targets Laravel 5.5–8.x. It may conflict with Laravel 10’s Eloquent improvements (e.g., attributes API) and PHP 8.2 features. Test thoroughly or use a maintained fork like spatie/laravel-encryption for modern Laravel.
- How do I configure which model fields get encrypted?
- Use the `$encrypts` property in your Eloquent model (e.g., `protected $encrypts = ['credit_card', 'ssn']`) or define global rules in `config/laravel-database-encryption.php`. The package automatically encrypts/decrypts these fields when saved/retrieved.
- Will encrypted fields break database queries like `where()` or `orderBy()`?
- Yes, encrypted fields cannot be used in queries (e.g., `where('encrypted_field', 'value')` will fail). Avoid querying encrypted columns directly. For searches, consider storing a hashed/sha256 version alongside encrypted data or using full-text search on non-encrypted fields.
- Can I encrypt only part of a JSON column (e.g., nested objects) or do I need full-field encryption?
- This package encrypts entire attributes, not sub-fields of JSON columns. To encrypt nested data, you’d need to manually serialize/deserialize the JSON or use a different approach like Laravel’s built-in `encrypt` helper for specific fields.
- How does key management work? Can I rotate encryption keys safely?
- Keys are stored in Laravel’s config (`config/laravel-database-encryption.php`). Rotating keys requires re-encrypting all data manually (e.g., via a seed or migration). For production, integrate with a KMS like AWS KMS or HashiCorp Vault for automated rotation.
- Does this package support hardware-backed encryption (e.g., AWS KMS, Azure Key Vault)?
- No, it relies on Laravel’s native `openssl` encryption with config-based keys. For hardware-backed encryption, pair this with a custom trait or use alternatives like spatie/laravel-encryption, which supports external key providers.
- What’s the performance impact of encrypting Eloquent attributes?
- Encryption adds overhead during save/retrieve operations. Benchmark your app: if most queries involve encrypted fields, performance may degrade. Mitigate by encrypting only highly sensitive data or using partial encryption (e.g., encrypting PII but not metadata).
- Can I use this alongside Laravel’s built-in `encrypt()` helper or other packages?
- Yes, the package is composable. You can mix it with Laravel’s `encrypt()` for field-level control or other security layers. However, avoid double-encrypting the same data, as it may cause decryption failures.
- How do I handle encrypted data in backups or migrations?
- Backups include encrypted data as-is. Restores require the decryption key to be available. For migrations, use `php artisan db:seed` to re-encrypt legacy data if keys change. Document your key storage process for disaster recovery.
- Are there alternatives to austinheap/laravel-database-encryption for Laravel 10+?
- Yes, consider modern alternatives like spatie/laravel-encryption (supports Laravel 9/10, field-level encryption, and key rotation) or Laravel’s native `encrypt` helper for simpler use cases. Evaluate based on your needs for hardware-backed keys or query flexibility.