Skip to content

Instantly share code, notes, and snippets.

@carteni
Last active February 9, 2017 11:23
Show Gist options
  • Save carteni/d702eaa4f7459edb06434a0856938942 to your computer and use it in GitHub Desktop.
Save carteni/d702eaa4f7459edb06434a0856938942 to your computer and use it in GitHub Desktop.
Symfony Validation / Caching ClassMetadata information using Predis and DoctrineCacheBundle.
<?php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
new AppBundle\AppBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
}
framework:
validation: { enable_annotations: true, cache: validator.mapping.cache.doctrine.predis_cache }
# $ composer require doctrine/doctrine-cache-bundle
# $ composer predis/predis
doctrine_cache:
aliases:
predis_cache: my_predis_cache
providers:
my_predis_cache:
type: predis
namespace: "%validator.mapping.cache.prefix%"
aliases:
- predis_cache
services:
validator.mapping.cache.doctrine.predis_cache:
class: Symfony\Component\Validator\Mapping\Cache\DoctrineCache
public: false
arguments: ["@predis_cache"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment