2
votes

Memcache error on yii migrate.

exception 'yii\base\InvalidConfigException' with message 'MemCache requires PHP memcache extension to be loaded.'

in /Applications/AMPPS/www/G2G/vendor/yiisoft/yii2/caching/MemCache.php:220

Stack trace: #0 /Applications/AMPPS/www/G2G/vendor/yiisoft/yii2/caching/MemCache.php(116): yii\caching\MemCache->getMemcache()

I have memcached installed on my laptop and in my php its active as well. But still getting above error. Any reason to this?

Config

 'cache' => [
        'class' => 'yii\caching\MemCache',
        'servers' => [
            [
                'host' => '127.0.0.1',
                'port' => 11211
            ],
        ],
    ],
2
Beware of the subtle difference between memcache and memcached. You may need to configure that library to use memcached and not memcacheapokryfos
@apokryfos It was working few days back. I am getting this error today only.Cristal
Show config of your cache component.rob006
@rob006 I have updated my questionCristal

2 Answers

3
votes

If you have installed memcached, you need to configure your component to use it:

'cache' => [
    'class' => 'yii\caching\MemCache',
    'useMemcached' => true,
    'servers' => [
        [
            'host' => '127.0.0.1',
            'port' => 11211
        ],
    ],
],

MemCache::$useMemcached documentation:

Whether to use memcached or memcache as the underlying caching extension. If true, memcached will be used. If false, memcache will be used. Defaults to false.

-2
votes
 'cache' => [
        'class' => 'yii\caching\FileCache',
    ],