walidtlili
walidtlili

Reputation: 1100

Attempted to call function "apcu_fetch" from namespace "Doctrine\Common\Cache"

I'm developping an application with symfony 3 and angular 5. my system is windows 10 and i'm using php7.2

All is done wih dev_mode, but when i'm turning on production mode i'm having this error :

Fatal error: Uncaught Symfony\Component\Debug\Exception\UndefinedFunctionException: Attempted to call function "apcu_fetch" from namespace "Doctrine\Common\Cache".

How can i install apcu ?

Upvotes: 0

Views: 2002

Answers (1)

OK sure
OK sure

Reputation: 2656

For PHP 7.x it would seem Symfony have removed the framework (validation and serializer) cache config in their default config_prod.yml and kept the ORM cache but using apc instead of apcu as they did previously. I saw the same issue on a project running on PHP 7.1.12 that I had started before this change.

I did manage to get APCU running by installing it and modifying the Symfony prod config but I would be inclined to do as Symfony do on this one. In case you are thinking of still using APCU and serialization & validator caching:

Install it on the server if it's not installed (this will vary from server to server but there are other articles out there explaining this):

pecl install apcu && echo "extension=apcu.so" > /usr/local/etc/php/conf.d/apcu.ini

Then in your services.yml add the following to configure the validator cache:

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

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

Then use that in your config_prod.yml:

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

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

Upvotes: 1

Related Questions