skip to Main Content

From phpinfo():
phpinfo, memcache is loaded

However, when I try to migrate, show this error:

Exception 'yiibaseInvalidConfigException' with message 'MemCache requires PHP memcache extension to be loaded.'

in /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/caching/MemCache.php:217

Stack trace:
#0 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/caching/MemCache.php(113): yiicachingMemCache->getMemcache()
#1 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Object.php(107): yiicachingMemCache->init()
#2 [internal function]: yiibaseObject->__construct(Array)
#3 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/di/Container.php(372): ReflectionClass->newInstanceArgs(Array)
#4 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/di/Container.php(151): yiidiContainer->build('yii\caching\Mem...', Array, Array)
#5 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/BaseYii.php(344): yiidiContainer->get('yii\caching\Mem...', Array, Array)
#6 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/di/ServiceLocator.php(133): yiiBaseYii::createObject(Array)
#7 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/db/Schema.php(275): yiidiServiceLocator->get('cache', false)
#8 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/db/Migration.php(71): yiidbSchema->refresh()
#9 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Object.php(107): yiidbMigration->init()
#10 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/controllers/MigrateController.php(113): yiibaseObject->__construct(Array)
#11 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(491): yiiconsolecontrollersMigrateController->createMigration('m170316_221710_...')
#12 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(129): yiiconsolecontrollersBaseMigrateController->migrateUp('m170316_221710_...')
#13 [internal function]: yiiconsolecontrollersBaseMigrateController->actionUp(0)
#14 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#15 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Controller.php(151): yiibaseInlineAction->runWithParams(Array)
#16 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/Controller.php(91): yiibaseController->runAction('', Array)
#17 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Module.php(455): yiiconsoleController->runAction('', Array)
#18 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/Application.php(167): yiibaseModule->runAction('migrate', Array)
#19 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/Application.php(143): yiiconsoleApplication->runAction('migrate', Array)
#20 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Application.php(375): yiiconsoleApplication->handleRequest(Object(yiiconsoleRequest))
#21 /Library/WebServer/Documents/r2d2/yii(27): yiibaseApplication->run()
#22 {main}

Could someone help me find out why?

Thanks!

2

Answers


  1. The error is from console application and phpinfo output is from webserver. So, you basically enabled memcache module for webserver but didn’t for console. To give exact solution more information about your setup is needed: what do you​ use, php-fpm, modapache? Please provide full phpinfo output either from web and cli

    UPDATE

    Check which directories your console PHP scans for additional ini-files:

    php -i | grep "Scan this dir for additional .ini files"
    

    Then you need to put configuration file (for example memcache.ini) with module config into one of those. Content should be like:

    extension=memcache.so
    

    You can check the one webserver uses for reference.

    Login or Signup to reply.
  2. If you use memcached instead memcache, then you need to add this line to config/console.php:

    'useMemcached' => true,
    

    it should look like:

    'components' => [
        'cache' => [
            'class' => 'yiicachingMemCache',
            'useMemcached' => true,
            'servers' => [
                [
    

    ….

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search