LoginSignup
0
0

More than 5 years have passed since last update.

validator.mapping.cache.doctrine.apcはSymfony 2.8から

Posted at

公式ドキュメントにも出てくるvalidator.mapping.cache.doctrine.apcサービスはSymfony 2.8からしか使えません。

config.yml
framework:
    validation:
        cache: validator.mapping.cache.doctrine.apc

2.7でも使えるものと思い込んでいましたが2.7でこのように定義してもサービスなしエラーになってしまいます。

2.8より前のバージョンでは

サービスが用意されていないので自前でサービス定義します。
以下サービス定義の一例

config.yml
framework:
    validation:
        cache: validator.mapping.cache.doctrine

services:
    validator.mapping.cache.doctrine:
        class: Symfony\Component\Validator\Mapping\Cache\DoctrineCache
        # ApcCache
        arguments: [@doctrine_cache.apc]
        # FilesystemCache
        #arguments: [@doctrine_cache.filesystem]

    doctrine_cache.apc:
        class: Doctrine\Common\Cache\ApcCache
        calls:
            - [setNamespace, [%validator.mapping.cache.prefix%]]

    doctrine_cache.filesystem:
        class: Doctrine\Common\Cache\FilesystemCache
        arguments:
            - %kernel.cache_dir%/validation
            - .php
        calls:
            - [setNamespace, [%validator.mapping.cache.prefix%]]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0