2

I receive the exception when configure the cache components in main configuration of basic-template, how I can fix this problem? app/config/web.php:

my php version is 7.1.11

'cache' => [
        'class' => 'yii\caching\ApcCache',
        'keyPrefix' => 'myapp',       // a unique cache key prefix
        'useApcu' => true,
        //'class' => 'yii\caching\MemCache',

],

I try memCache but still same error show

enter image description here

yasir shah
  • 73
  • 1
  • 9
  • Does this answer your question? [Yii2 Exception: ApcCache requires PHP apc extension to be loaded](https://stackoverflow.com/questions/45460796/yii2-exception-apccache-requires-php-apc-extension-to-be-loaded) – rob006 Dec 10 '19 at 09:17

1 Answers1

2

you need to install the extension, on Ubuntu you can do as following:

For Ubuntu / Debian

sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart

For CentOS / Fedora

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install php-pecl-apcu
sudo yum install php-pear php-devel httpd-devel pcre-devel gcc make

Here is a guide for how to install on Windows: http://robert-rusu.blogspot.com/2014/06/install-apcu-on-windows.html

This should resolve your issue.

ghovat
  • 1,033
  • 1
  • 12
  • 38
  • thanks ghovat but when i execute your code in cmd the error 'sudo' is not recognized as an internal or external command,operable program or batch file. – yasir shah Dec 09 '19 at 17:18
  • kindly give me instruction how to execute this code – yasir shah Dec 09 '19 at 17:19
  • Try to run it without sudo I guess you are in a docker? Which OS are you using? – ghovat Dec 09 '19 at 17:59
  • I try it without sudo but nothing happend. The OS window 10 – yasir shah Dec 10 '19 at 04:58
  • what's ```apt-get``` is there any alternate of ```apt-get```? – yasir shah Dec 10 '19 at 05:04
  • My php compiler is ``MSVC14 (Visual C++ 2015)`` and Architecture ``X86`` – yasir shah Dec 10 '19 at 05:34
  • Hi, sorry I assumed you were running on Linux, here is a short tutorial on how to install the extension on Windows: http://robert-rusu.blogspot.com/2014/06/install-apcu-on-windows.html – ghovat Dec 10 '19 at 09:06
  • I appreciate your answer and try it all things and latest version ``5.1.18 stable DLL`` and ``php 7.1 Thread Safe (NTS) x64 `` but still show error – yasir shah Dec 10 '19 at 12:55
  • can you verify that in your php.ini apcu is enabled: https://secure.php.net/manual/en/opcache.installation.php further can you follow the `php apc extension` installation for Windows builds https://www.php.net/manual/en/apc.installation.php Not as fix but to get it working you can also disable the alternative php cache: with ` 'useApcu' => false,` – ghovat Dec 10 '19 at 14:11
  • Yes i follow all the instruction add file ``php_apcu.dll`` file in ``php extension folder`` and also add in ``php.ini`` file and restart the xampp and add this code in my confiq file ``'cache' => [ 'class' => 'yii\caching\ApcCache', 'useApcu' => false, ],`` – yasir shah Dec 10 '19 at 14:42
  • yup! i try it but still nothing happened. – yasir shah Dec 10 '19 at 15:50