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?

  • Opcache has been available, built into PHP since 5.5, might want to look into it. – Devon Bessemer Dec 30 '15 at 21:50
  • Yes, but APCu is better for Symfony. –  Dec 30 '15 at 21:51
  • 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 cli – FZE Jan 21 '16 at 20:34
  • APC is very buggy especially in newer PHP versions. – René Höhle Jan 21 '16 at 20:34
  • 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 apc**u**_fetch() all works fine –  Jan 21 '16 at 20:36

4 Answers4

20

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

François Breton
  • 1,158
  • 14
  • 24
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.

Thomas Decaux
  • 21,738
  • 2
  • 113
  • 124
Tobske
  • 518
  • 3
  • 12
3

If you use ubuntu:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php-apcu-bc
  • This answer contains the solution that worked for me. Be good if you fleshed it out a bit more. Thx. – Henry Sep 14 '17 at 00:34
1

On MacOS, using pecl is a one-command solution (after a brew install php@7.1) :

pecl install apcu

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

sglessard
  • 3,097
  • 2
  • 27
  • 31