PHPackages                             nowo-tech/doctrine-encrypt-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. nowo-tech/doctrine-encrypt-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

nowo-tech/doctrine-encrypt-bundle
=================================

Encrypt Doctrine entity fields at rest with Halite or Defuse. Symfony 7|8 bundle for field-level encryption, GDPR-friendly, multiple keys, key rotation.

v2.0.10(2mo ago)1366↓47.1%[2 PRs](https://github.com/nowo-tech/DoctrineEncryptBundle/pulls)MITPHPPHP &gt;=8.1CI passing

Since Feb 19Pushed 1mo agoCompare

[ Source](https://github.com/nowo-tech/DoctrineEncryptBundle)[ Packagist](https://packagist.org/packages/nowo-tech/doctrine-encrypt-bundle)[ Docs](https://github.com/nowo-tech/DoctrineEncryptBundle)[ RSS](/packages/nowo-tech-doctrine-encrypt-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (15)Used By (0)

Doctrine Encrypt Bundle
=======================

[](#doctrine-encrypt-bundle)

[![CI](https://github.com/nowo-tech/DoctrineEncryptBundle/actions/workflows/ci.yml/badge.svg)](https://github.com/nowo-tech/DoctrineEncryptBundle/actions/workflows/ci.yml) [![Packagist Version](https://camo.githubusercontent.com/86086fa8a2de5515df080144f5610319d2b42dd9903e745ee3030bbecb2439d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f776f2d746563682f646f637472696e652d656e63727970742d62756e646c652e7376673f7374796c653d666c6174)](https://packagist.org/packages/nowo-tech/doctrine-encrypt-bundle) [![Packagist Downloads](https://camo.githubusercontent.com/8a0cec4f090a55f550db0c20bb029be942eababf98855732e2d5a356c82580ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6f776f2d746563682f646f637472696e652d656e63727970742d62756e646c652e737667)](https://packagist.org/packages/nowo-tech/doctrine-encrypt-bundle) [![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE) [![PHP](https://camo.githubusercontent.com/8e58b490725ac49cc8e463c473173681b324c9d92d7854275a785db013ca3de7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d3737374242343f6c6f676f3d706870)](https://php.net) [![Symfony](https://camo.githubusercontent.com/14a8a35146549d981b2ec9e844832719c6d44417e478603dbbd9bebb50a0fcc1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d37253230253743253230382d3030303030303f6c6f676f3d73796d666f6e79)](https://symfony.com) [![GitHub stars](https://camo.githubusercontent.com/feb6c53282f825812e44e110399a85f6435d32be179a6e58a619a06d2860189c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e6f776f2d746563682f646f637472696e652d656e63727970742d62756e646c652e7376673f7374796c653d736f6369616c266c6162656c3d53746172)](https://github.com/nowo-tech/DoctrineEncryptBundle) [![Coverage](https://camo.githubusercontent.com/cd0704b56f1d56def350b6d0164316307bb2f47834225fd85443b6fb0059bc73/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f7665726167652d3130302532352d627269676874677265656e)](#tests-and-coverage)

**Symfony bundle to encrypt Doctrine entity fields at rest** using [Halite](https://github.com/paragonie/halite) or [Defuse](https://github.com/defuse/php-encryption)—audited libraries, no custom crypto. For **Symfony 7 and 8** · PHP 8.1+. Suits **GDPR** and compliance (e.g. Art. 32); supports key rotation and [Nowo\\AnonymizedBundle](https://github.com/nowo-tech/AnonymizedBundle) for anonymization and erasure.

> ⭐ **Found this useful?** [Install from Packagist](https://packagist.org/packages/nowo-tech/doctrine-encrypt-bundle) · Give it a **star** on [GitHub](https://github.com/nowo-tech/DoctrineEncryptBundle) so more developers can find it.

Table of contents
-----------------

[](#table-of-contents)

- [Quick search terms](#quick-search-terms)
- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Documentation](#documentation)
- [Requirements](#requirements)
- [Demo](#demo)
- [Development](#development)
- [License &amp; author](#license--author)

Quick search terms
------------------

[](#quick-search-terms)

Looking for **Doctrine encryption**, **encrypt entity fields**, **Halite Symfony**, **Defuse encryption**, **field-level encryption**, **encrypt database column**, **Symfony encrypt attribute**, **Doctrine Encrypted**? You're in the right place.

Features
--------

[](#features)

- ✅ Encrypt and decrypt entity properties with a single attribute
- ✅ **Multiple encryptor configs** — e.g. `personal_data` (Halite) and `financial_data` (Defuse) in the same app, each with its own key
- ✅ **Halite** and **Defuse** — audited crypto libraries, no custom algorithms
- ✅ Transparent: encrypt on persist/update, decrypt on load
- ✅ **EncryptUtil** — programmatic `encrypt()` / `decrypt()` with optional config name (default or e.g. `financial_data`)
- ✅ **MaskUtil** — mask sensitive values in PHP (e.g. show only last N chars); usable in services
- ✅ **Twig filters** — `|decrypt` (decrypt in templates; optional config: `{{ value|decrypt }}` or `{{ value|decrypt('financial_data') }}`) and `|mask` (mask for display: `{{ value|mask(4) }}` or `{{ value|decrypt|mask(4) }}`)
- ✅ Works with **embedded entities** and **inheritance**
- ✅ Console commands: status, generate secret key, encrypt/decrypt database, **rotate keys** (backup, decrypt, change keys, re-encrypt with confirmations)
- ✅ **Key rotation** — one command or manual steps; combinable with [Nowo\\AnonymizedBundle](https://github.com/nowo-tech/AnonymizedBundle) for GDPR-compliant anonymization and erasure
- ✅ **Symfony Flex** recipe (register bundle + config; see [docs/INSTALLATION.md](docs/INSTALLATION.md))
- ✅ Compatible with **Symfony 7 and 8** and **Doctrine ORM 2.x and 3.x**
- ✅ Compatible with **FrankenPHP** (HTTP runtime and optional **worker** mode; demos default to **`APP_ENV=dev`** with **Caddyfile.dev**, i.e. no PHP worker — see [docs/DEMO-FRANKENPHP.md](docs/DEMO-FRANKENPHP.md) and [Installation → FrankenPHP](docs/INSTALLATION.md#frankenphp-runtime-and-worker-mode))

Installation
------------

[](#installation)

```
composer require nowo-tech/doctrine-encrypt-bundle
```

[![Install from Packagist](https://camo.githubusercontent.com/25ba1d8b573a14c09873ad1c973fe17a929432bcf6cf4ceca6fa0910e34c5d08/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5061636b61676973742d696e7374616c6c2d3737374242343f6c6f676f3d636f6d706f736572)](https://packagist.org/packages/nowo-tech/doctrine-encrypt-bundle)

With **Symfony Flex**, the recipe (when enabled) registers the bundle and creates the config file automatically. Without Flex, see [docs/INSTALLATION.md](docs/INSTALLATION.md) for manual steps.

**Manual registration** in `config/bundles.php`:

```
