I have updated yii2 through composer from Yii v2.0.5 to v2.0.15.1.
I expected no major breaking issue, and my application to work as is
Invalid Configuration – yii\base\InvalidConfigException
ApcCache requires PHP apc extension to be loaded.
in C:\xampp71\htdocs\myapp\vendor\yiisoft\yii2\caching\ApcCache.php line 47
The offending code is:
public function init()
{
parent::init();
$extension = $this->useApcu ? 'apcu' : 'apc';
if (!extension_loaded($extension)) {
throw new InvalidConfigException("ApcCache requires PHP $extension extension to be loaded.");
}
}
My web.php config file:
'cache' => [
'class' => 'yii\caching\FileCache',
],
I have tried changing the config to below but the issue couldn't be resolved:
'cache' => [
'class' => 'yii\caching\ApcCache',
'useApcu' => true,
],
The only fix that worked is to explicitly change
public $useApcu = false;
in the ApcCache class to
public $useApcu = true;
| Q | A
| ---------------- | ---
| Yii version | 2.0.15.1?
| PHP version | 7.1.1
| PHP Compiler | MSVC14 (Visual C++ 2015)
| Architecture | x86
| Apache Version | Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/7.1.1
| Operating system | Windows 7 Professional Edition Service Pack 1
Thanks for posting in our issue tracker.
In order to properly assist you, we need additional information:
Thanks!
_This is an automated comment, triggered by adding the label status:need more info._
I would do a search in my code to see if there's any references to Apc that I'm not aware off.
Maybe there's an old config file.
After keenly looking at the Stack Trace, turns out the issue emanates from the urlManager configuration... when the enablePrettyUrl property is set to true , for some reason the urlManager is trying to look into the APC cache.
So the safest workaround on my part now is to set cache property of urlManager to false, and leave the ApcCache core class the way it was.
I'd still search for any APC usage, UrlManager should just use which ever cache component you've set and not exclusively APC
Another thing I've noticed, any reference to Yii::$app->cache... defaults to ApcCache.
I don't have any other config files apart from the standard ones in the config folder.
I'd still search for any APC usage,
UrlManagershould just use which ever cache component you've set and not exclusivelyAPC
My huge config file had another reference of ApcCache several lines down which I had included to do some tests. Stupid me.
This issue now stands closed.
Most helpful comment
My huge config file had another reference of ApcCache several lines down which I had included to do some tests. Stupid me.
This issue now stands closed.