config_cache_enabled Errors

2019-05-17 12:41发布

问题:

Using Zend Framework 2.1

When I set 'config_cache_enabled' => true inside of my application.config.php

It's returning the following error:

Warning: var_export does not handle circular references in /usr/local/apache/vhosts/otwebsoft_admin/vendor/Zend/ModuleManager/Listener/AbstractListener.php on line 67

After a few refreshes of the page then I get this:

Fatal error: Call to undefined method Zend\Cache\Storage\Adapter\Apc::__set_state() in /usr/local/apache/vhosts/otwebsoft_admin/data/cache/module-config-cache.otwebsoft.php on line 181

I can see now that file is created on the server. Of course setting the value back to false in the config removes all the errors. But now we have loss of cacheing functionality.

Yes, I am using the APC Adapter for my cache.

Reading the PHP documentation it recommends to use serialize. So I looked at the source code and changed the var_export to serialize and that removes that error, but it brings back the 2nd error listed here.

Any ideas?

回答1:

I've finally figured this out. I don't know why it took me so long but everything makes sense now.

So a closure would be something like:

'example' => factory()
{
    return new Example();
}

Where-as I should be using (for example):

'example' => 'Module/Service/Example'

After I removed all the closures I'm now able to use

'config_cache_enabled' => true