zend框架缓存中的Clousure错误

Error with Clousure in zend framework cache

我的 Zend Framework 缓存有问题 - 当我将我的应用程序投入生产时出现此错误。

Fatal error: Uncaught Error: Call to undefined method Closure::__set_state() in /home/users/devmonitoring/data/cache/module-config-cache.application.config.cache.php:67 

Stack trace: 
#0 /home/users/devmonitoring/vendor/zendframework/zend-modulemanager/src/Listener/ConfigListener.php(392): include() 
#1 /home/users/devmonitoring/vendor/zendframework/zend-modulemanager/src/Listener/ConfigListener.php(70): Zend\ModuleManager\Listener\ConfigListener->getCachedConfig() 
#2 /home/users/devmonitoring/vendor/zendframework/zend-modulemanager/src/Listener/DefaultListenerAggregate.php(98): Zend\ModuleManager\Listener\ConfigListener->__construct(Object(Zend\ModuleManager\Listener\ListenerOptions)) 
#3 /home/users/devmonitoring/vendor/zendframework/zend-modulemanager/src/Listener/DefaultListenerAggregate.php(42): Zend\ModuleManager\Listener\DefaultListenerAggregate->getConfigListener() 
#4 /home/users/devmonitoring/vendor/zendframework/zend-mvc/src/Service/ModuleManagerFactory.php(77): Zend\ModuleManager\Listener\DefaultListenerAggregate-> in /home/users/devmonitoring/data/cache/module-config-cache.application.config.cache.php on line 67

我尝试清除缓存,但仍然出现此错误。

当您为配置文件打开缓存时,您将 PHP 设置为它无法执行的任务,即闭包序列化。根本做不到。

Additionally you will lose the ability to use the caching feature of the configuration files when you use closures within them. This is a limitation of PHP which can’t (de)serialize closures.

https://framework.zend.com/manual/2.2/en/modules/zend.service-manager.quick-start.html

换句话说,你必须求助于工厂。