Symfony / PHP7 APC -> APCu
Asked Answered
D

4

12

I have issue with PHP7 and APCu. After installation I got this error:

Fatal error: Call to undefined function Doctrine\Common\Cache\apc_fetch()

APCu is 100% enabled, I see it in the phpinfo(); And when I try apcu_fetch() it works.

How to use APCu in Symfony 2.8?

Deroo answered 30/12, 2015 at 21:29 Comment(5)
Opcache has been available, built into PHP since 5.5, might want to look into it.Ceric
Yes, but APCu is better for Symfony.Deroo
Do you get this error on command line or on the client which connects to fpm ? Anway just reminding, if you get this error on commandline, you may miss php.ini can be different by fpm and cliMonstrosity
APC is very buggy especially in newer PHP versions.Chukchi
In php.ini I have this extension=apcu.so apc.enabled = 1 And in phpinfo I see APCU like Enabled.. So it's OK. But in command line I have this error: Fatal error: Call to undefined function Doctrine\Common\Cache\apc_fetch() If I try apcu_fetch() all works fineDeroo
D
9

This answer is obsolet. The correct answer is the one from François Breton.

In PHP 7 you have to add an additional module to your PHP setup: apc.so This is a module that enables backward compability to apc for apcu. This is kind of confusing...

See http://php.net/manual/de/apcu.installation.php for more info.

If you are using packages from https://deb.sury.org/ (ondrej ppa), you can install it via apt-get install php-apcu-bc.

Dagenham answered 16/2, 2016 at 14:29 Comment(1)
Could you please expand your answer in how to add the module?Isochor
L
20

You can update Doctrine, at least its doctrine/cache dependency (>= 1.6) APCu now supported :-)

Ladon answered 9/6, 2016 at 19:11 Comment(1)
Confirmed. Just change all your configs where you have apc to apcu eg metadata_cache_driver: apcuAnoa
D
9

This answer is obsolet. The correct answer is the one from François Breton.

In PHP 7 you have to add an additional module to your PHP setup: apc.so This is a module that enables backward compability to apc for apcu. This is kind of confusing...

See http://php.net/manual/de/apcu.installation.php for more info.

If you are using packages from https://deb.sury.org/ (ondrej ppa), you can install it via apt-get install php-apcu-bc.

Dagenham answered 16/2, 2016 at 14:29 Comment(1)
Could you please expand your answer in how to add the module?Isochor
A
3

If you use ubuntu:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php-apcu-bc
Annulus answered 13/7, 2017 at 2:33 Comment(1)
This answer contains the solution that worked for me. Be good if you fleshed it out a bit more. Thx.Anisette
W
1

On MacOS, using pecl is a one-command solution (after a brew install [email protected]) :

pecl install apcu

downloading apcu-5.1.17.tgz ...
[...]
Installing '/usr/local/Cellar/[email protected]/7.1.27/pecl/20160303/apcu.so'
install ok: channel://pecl.php.net/apcu-5.1.17
Extension apcu enabled in php.ini

Widmer answered 2/4, 2019 at 21:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.