3
votes

I have a problem with APCu and PHP7 again. Here is my conf.

framework:
    validation:
        cache: validator.mapping.cache.doctrine.apc
    serializer:
        cache: serializer.mapping.cache.apc

doctrine:
    orm:
        metadata_cache_driver: apcu
        result_cache_driver: apcu
        query_cache_driver: apcu

Website works ok, but when I send a form, I always get this error:

[2016-06-29 09:17:12] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\UndefinedFunctionException: "Attempted to call function "apc_fetch" from namespace "Doctrine\Common\Cache"." at ROUTE_TO_PROJECT/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php line 41 {"exception":"[object] (Symfony\Component\Debug\Exception\UndefinedFunctionException(code: 0): Attempted to call function \"apc_fetch\" from namespace \"Doctrine\Common\Cache\". at ROUTE_TO_PROJECT/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php:41)"} []

here is my composer:

"require": {
    "php": ">=5.5.9",
    "symfony/symfony": "3.0.*",
    "doctrine/orm": "^2.5",
    "doctrine/doctrine-bundle": "^1.6",
    "doctrine/doctrine-cache-bundle": "^1.2",
    "symfony/swiftmailer-bundle": "^2.3",
    "symfony/monolog-bundle": "^2.8",
    "sensio/distribution-bundle": "^5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "^2.0",
    "knplabs/knp-paginator-bundle": "^2.5",
    "liip/imagine-bundle": "^1.5",
    "jms/serializer-bundle": "^1.1",
    "symfony/assetic-bundle": "^2.8",
    "gopay/payments-sdk-php": "^1.1",
    "knplabs/knp-snappy-bundle": "~1.4",
    "friendsofsymfony/user-bundle": "~2.0@dev"

Why is Symfony call apc_fetch instead apcu_fatch?

3

3 Answers

5
votes

In previous versions of APCu, the APC module and functions were provided as part of the library.

In the most recent (PHP 7) versions of APCu, backward compatible APC is a separate extension.

4
votes

This is my solution:

services.yml

serializer.mapping.cache.apcu:
    class: Doctrine\Common\Cache\ApcuCache

confing_prod.yml

serializer:
    cache: serializer.mapping.cache.apcu

Idk if this solution is ok, but looks like it works. So if you know better solution, I would like to use it.

4
votes

You can get apcu working with symfony validation using the doctrine cache wrapper

config.yml

validation:
    cache: validator.mapping.cache

services.yml

doctrine.apcu.cache:
      class: Doctrine\Common\Cache\ApcuCache

validator.mapping.cache:
      class: Symfony\Component\Validator\Mapping\Cache\DoctrineCache
      arguments: ['@doctrine.apcu.cache']