GithubHelp home page GithubHelp logo

doctrine-encoded-cache-bundle's Introduction

Doctrine Encoded Cache Bundle

This bundle integrates a Symfony2 application with the trt/doctrine-encoded-cache library.

##Why cache encoding? Because sometimes there is the need to make the cached data unreadable. Think about high confidential data.
Only database servers are authorized to store datas.

How?

Cached data will be encrypted/decripted with AES256 (php-mcrypt extension is required)

Installation

run php composer.phar require trt/doctrine-encrypted-cache-bundle:~0.1

Create your KeyProvider

Put the following lines with Symfony Kernel

    public function registerBundles()
    {
        $bundles = array(

            new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
            new Trt\Doctrine\Cache\Bundle\DoctrineEncodedCacheBundle()
        );
        
    }

For security reason it's your responsability to store the encoding key in a safe place, so a key provider service is mandatory.

Create your own service implementing the KeyProvider interface.

Example:

class CacheKeyProvider implements \Trt\Doctrine\Cache\Key\KeyProvider
{

    /**
     * Provide the encoding key string.
     *
     * @return String
     */
    public function getKey()
    {
        return $this->fetchKeyFromASafePlace();
    }
}

Register the service:

services:
  my_bundle.cache.key_provider:
   class: My\Bundle\CacheKeyProvider

Full Configuration

According to the DoctrineCacheBundle documentation, configure the cache service

## An Example with apc cache
doctrine_cache:
    aliases:
        cache_apc: my_apc_cache

    providers:
        my_apc_cache:
            type: apc
            namespace: my_apc_cache_ns
            aliases:
                - apc_cache

doctrine_encoded_cache:
  key_provider: my_bundle.cache.key_provider #Your key provider service
  cache: apc_cache #The doctrine cache service


# Enable the doctrine ORM cache
doctrine:
	orm:
	    result_cache_driver:
	        type: service
	        id: doctrine_encoded_cache 
	    metadata_cache_driver:
	        type: service
	        id: doctrine_encoded_cache
	    query_cache_driver:
	        type: service
	        id: doctrine_encoded_cache

doctrine-encoded-cache-bundle's People

Contributors

toretto460 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.