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)618.1k↑544.4%4MITPHPPHP ^7.2|^8.0|^8.1|^8.2|^8.3CI passing

Since Dec 4Pushed 1mo 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 2d ago

READMEChangelog (10)Dependencies (6)Versions (17)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

54

—

FairBetter than 96% of packages

Maintenance61

Regular maintenance activity

Popularity34

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 52.2% 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

850d 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)")[![jensilo](https://avatars.githubusercontent.com/u/46793176?v=4)](https://github.com/jensilo "jensilo (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![cehmke-gracious](https://avatars.githubusercontent.com/u/53606724?v=4)](https://github.com/cehmke-gracious "cehmke-gracious (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

[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.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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