PHPackages                             dayploy/doctrine-extensions-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. dayploy/doctrine-extensions-bundle

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

dayploy/doctrine-extensions-bundle
==================================

1.0.1(7mo ago)0502↓25%MITPHPPHP ^8.2

Since Oct 8Pushed 3mo agoCompare

[ Source](https://github.com/dayploy/DayployDoctrineExtensionsBundle)[ Packagist](https://packagist.org/packages/dayploy/doctrine-extensions-bundle)[ Docs](https://github.com/dayploy/DayployDoctrineExtensionsBundle)[ RSS](/packages/dayploy-doctrine-extensions-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

DayployDoctrineExtensionsBundle
===============================

[](#dayploydoctrineextensionsbundle)

Encrypt your sensitive data in your database.

How it works
============

[](#how-it-works)

Your property is in your entity but not stored directly in the database.

Before persisting in db, it is encrypted using a `nonce` and the encrypted value is stored in the `encryptedValue`.

The reverse process is done when the entity is loaded from the db.

Anyone that acces your db can not read the value without the encryption key.

Entity update
=============

[](#entity-update)

In your entity, add your cryptable property. This property is not stored in database.

It can be nullable or not, it depends of your context, but it must be a string.

In this example: $myValue.

The nonce and encrypted value must be stored in binary.

```
#[ORM\Entity()]
class MyClass
{
    #[Cryptable(
        nonceProperty: 'myValueNonce',
        encryptedProperty: 'myValueEncrypted',
    )]
    private ?string $myValue = null; // this value is not stored in DB

    #[ORM\Column(type: Types::BINARY, nullable: true, length: 2500)]
    private ?string $myValueEncrypted = null;
    #[ORM\Column(type: Types::BINARY, nullable: true)]
    private ?string $myValueNonce = null;

    ...
}
```

Configuration
=============

[](#configuration)

Add the bundle to your project
------------------------------

[](#add-the-bundle-to-your-project)

```
composer require dayploy/doctrine-extensions-bundle
```

Enable the bundle
-----------------

[](#enable-the-bundle)

Add the bundle to `config/bundles.php`:

```
