Search code examples
cachingyii2apcphp-extensionopcache

Alternative to APC in Yii2


I developed a website using Yii2 Framework, and while I didn't explicitly use the Cache features, I guess it does do some things using APC as default.

The client where I published the website had uninstalled APC, since it is deprecated since v5.5 and refuse to install the extension.

My client now keeps receiving an 'unable to load dynamic library - apc.so' every time they try to save or delete a record to the database, not read.

I tried to clear the cache sub folder under the runtime folder in hopes that the website will use whatever system is available, but the error still creeps up.

They are using opcache. How can I reconfigure yii to use opcache and prevent the inability to find apc.so error?

EDIT:

This is what I have under components.

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

Solution

  • If your cache is properly configured you should find something like this in the configuration file:

    'components' => [
        'cache' => [
            'class' => 'yii\caching\ApcCache',
        ],
    ],
    

    Now, AFAIK OpCache does not require configuration on the code level so you don't have to replace this config with something OpCache specific but there are direct cache calls in your code (hence the error) so you may want to use some available cache component anyway. In case you don't want to use any new cache component and at the same time you don't want to remove cache calls in your code use DummyCache:

    'cache' => [
        'class' => 'yii\caching\DummyCache',
    ],
    

    EDIT:

    It looks like it is not a case of Yii 2 configuration, more like a PHP configuration. Look for "unable to load dynamic library - apc.so". Probably APC is still in the PHP configuration but the library has been removed. Related questions: