PHP code example of epsoftware / doctrine-odm-encrypt

1. Go to this page and download the library: Download epsoftware/doctrine-odm-encrypt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

epsoftware / doctrine-odm-encrypt example snippets




$encrypter = $this->app->make(\Illuminate\Contracts\Encryption\Encrypter::class);

$subscriber = new DoctrineEncryptSubscriber(
    new \Doctrine\Common\Annotations\AnnotationReader,
    new \DoctrineEncrypt\Encryptors\LaravelEncryptor($encrypter)
);

$eventManager = $em->getEventManager();
$eventManager->addEventSubscriber($subscriber);



namespace Your\Namespace;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

use DoctrineEncrypt\Configuration\Encrypted;

/**
 * @ODM\Document
 */
class Document
{
    /**
     * @ODM\Id
    */
    private $id;

    /**
     * @ODM\Field(type="string")
     * @Encrypted
     * @var string
     */
    private $secretData;
}