Doctrine undefined function apc_fetch

2019-04-04 08:09发布

问题:

I'm using this tutorial, which gives a detail explanation about how to set up CodeIgniter and Doctrine. I'm using CodeIgniter 2.1.0 and Doctrine 2.2.1, but I get this error:

Fatal error: Call to undefined function Doctrine\Common\Cache\apc_fetch() in /Applications/XAMPP/xamppfiles/htdocs/emma_watson_shrine/application/libraries/Doctrine/Common/Cache/ApcCache.php on line 52

Can you help me out?

回答1:

You need to enable the APC extension for PHP.

Follow this guide.

Alternatively, you could use a different caching driver, like memcache, and change the Doctrine config in accordance to that.

Check the doctrine documentation for alternate caching drivers. Perhaps the simplest solution would be to use ArrayCache in development.



回答2:

If you don't install APC and just want to run it then in doctrine-cli.php at line 6, change mode:

define('ENVIRONMENT', 'production');

to

define('ENVIRONMENT', 'development');

Open Doctrine.php file, at line 36 ~ 43, you will see why!



回答3:

Since php 5.5 apc is no longer used. You should install apcu.

E.g.

apt install php5.6-apcu

More info here:

http://php.net/manual/en/opcache.installation.php

And for those on php 7 there's a backwards compatibility module:

apt-get install php7.0-apcu
apt-get install php7.0-apcu-bc

Also, you might need to add this repository:

apt-add-repository ppa:ondrej/php
apt-get update


回答4:

you need to install apc extension to work with caching. So just download the extension and install it.

This one will help you to install APC extension on apache.

http://kvcodes.com/2014/06/solution-call-undefined-function-apc_fetch/



回答5:

For anyone getting this on a Mac, just install apcu using Homebrew:

brew install php56-apcu

(and enable the extension, if required).



回答6:

On OSX I had to run:

pecl channel-update pecl.php.net
pecl install apcu-4.0.11

to install for PHP 5.6

https://getgrav.org/blog/macos-mojave-apache-mysql-vhost-apc