PHPackages                             gracious/doctrine-encryption-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. gracious/doctrine-encryption-bundle

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

gracious/doctrine-encryption-bundle
===================================

Simple bundle for adding encryption type to Doctrine

5.0.0(2y ago)514.0k↑50%4MITPHPPHP ^7.2|^8.0|^8.1|^8.2|^8.3CI failing

Since Dec 4Pushed 1y ago5 watchersCompare

[ Source](https://github.com/graciousagency/doctrine-encryption-bundle)[ Packagist](https://packagist.org/packages/gracious/doctrine-encryption-bundle)[ RSS](/packages/gracious-doctrine-encryption-bundle/feed)WikiDiscussions master Synced 1mo ago

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

Gracious Doctrine Encryption Bundle
===================================

[](#gracious-doctrine-encryption-bundle)

Simple bundle to add 2 new types to Doctrine

- encrypted
- encryptedArrayCollection
- hashed

It relies on libSodium for encryption

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

[](#installation)

The Installation is quite simple:

1. Require the Bundle via composer:

```
composer require gracious/doctrine-encryption-bundle

```

2. Add the following to your doctrine.yaml:

```
types:
  encrypted: 'Gracious\DoctrineEncryptionBundle\Type\Encrypted'
  encryptedArrayCollection: 'Gracious\DoctrineEncryptionBundle\Type\EncryptedArrayCollection'
  hashed: 'Gracious\DoctrineEncryptionBundle\Type\Hashed'
```

3. Generate a 64 character encryption key, you could to this the following way:

```
sodium_bin2hex(random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES));
```

4. Add the following two settings to your .env file:

```
ENABLE_ENCRYPTION=true
ENCRYPTION_KEY=[PASTE ENCRYPTION KEY HERE]

```

Settings
--------

[](#settings)

There are 2 settings at the moment, both are env vars

- ENABLE\_ENCRYPTION - true / false
- ENCRYPTION\_KEY - 64 character hexadecimal string

Generating a key
----------------

[](#generating-a-key)

You can do 2 things to generate a key, either type one yourself or run:

```
sodium_bin2hex(random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES));
```

Nonce
-----

[](#nonce)

Nonces are automatically generated for each encrypted value and are added to the returned value as follows:

```

```

Doctrine settings
-----------------

[](#doctrine-settings)

The following has to be added to you doctrine.yaml

```
types:
  encrypted: 'Gracious\DoctrineEncryptionBundle\Type\Encrypted'
  encryptedArrayCollection: 'Gracious\DoctrineEncryptionBundle\Type\EncryptedArrayCollection'
  hashed: 'Gracious\DoctrineEncryptionBundle\Type\Hashed'
```

The block would look something like this:

```
doctrine:
    dbal:
        # configure these for your database server
        driver: 'pdo_mysql'
        server_version: '5.7'
        charset: utf8mb4
        default_table_options:
            charset: utf8mb4
            collate: utf8mb4_unicode_ci

        # With Symfony 3.3, remove the `resolve:` prefix
        url: '%env(resolve:DATABASE_URL)%'
        types:
          encrypted: 'Gracious\DoctrineEncryptionBundle\Type\Encrypted'
          encryptedArrayCollection: 'Gracious\DoctrineEncryptionBundle\Type\EncryptedArrayCollection'
          hashed: 'Gracious\DoctrineEncryptionBundle\Type\Hashed'
```

Usage
-----

[](#usage)

To use either of the 3 types in your entity just replace the column type with

```
@ORM\Column(type="encrypted")

```

or

```
@ORM\Column(type="encryptedArrayCollection")

```

or

```
@ORM\Column(type="hashed")

```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 54.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~192 days

Recently: every ~316 days

Total

11

Last Release

804d ago

Major Versions

1.2.0 → 2.0.02020-09-18

2.0.0 → 3.0.02021-01-11

3.0.1 → 4.0.02024-03-06

4.0.0 → 5.0.02024-03-06

PHP version history (4 changes)1.0.0PHP ^7.2

3.0.0PHP ^7.2|^8.0

3.0.1PHP ^7.2|^8.0|^8.1|^8.2

5.0.0PHP ^7.2|^8.0|^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/21ae8d3f83f03a3c3a6f31de17ec1964ae26f1af703069284f650ed676211d4c?d=identicon)[gracious](/maintainers/gracious)

---

Top Contributors

[![michaelgracious](https://avatars.githubusercontent.com/u/24290969?v=4)](https://github.com/michaelgracious "michaelgracious (12 commits)")[![zepich](https://avatars.githubusercontent.com/u/391914?v=4)](https://github.com/zepich "zepich (4 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (3 commits)")[![agneschristine](https://avatars.githubusercontent.com/u/25481520?v=4)](https://github.com/agneschristine "agneschristine (1 commits)")[![cehmke-gracious](https://avatars.githubusercontent.com/u/53606724?v=4)](https://github.com/cehmke-gracious "cehmke-gracious (1 commits)")[![jensilo](https://avatars.githubusercontent.com/u/46793176?v=4)](https://github.com/jensilo "jensilo (1 commits)")

---

Tags

doctrinedoctrine-dbaldoctrine-encryption-bundledoctrine2encryptionhashinglibsodium-phpphp72php8symfony-bundlesymfony4encryptionhashingdoctrine

### Embed Badge

![Health badge](/badges/gracious-doctrine-encryption-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/gracious-doctrine-encryption-bundle/health.svg)](https://phpackages.com/packages/gracious-doctrine-encryption-bundle)
```

###  Alternatives

[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

813.1k](/packages/ahmed-bhs-doctrine-doctor)[easycorp/easyadmin-demo

EasyAdmin Demo Application

145.7k](/packages/easycorp-easyadmin-demo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
