【发布时间】:2018-08-22 14:37:48
【问题描述】:
我正在尝试将 zend-cache 与 zend-rbac 一起使用。
zend-rbac 没问题,但是当我尝试添加 zend-cache 时,我收到了以下消息:
无法将服务“FilesystemCache”解析为工厂;你确定你是在配置时提供的吗?
我在 global.php 的缓存配置是这样的:
// Cache configuration.
'caches' => [
'FilesystemCache' => [
'adapter' => [
'name' => Filesystem::class,
'options' => [
// Store cached data in this directory.
'cache_dir' => './data/cache',
// Store cached data for 1 hour.
'ttl' => 60*60*1
],
],
'plugins' => [
[
'name' => 'serializer',
'options' => [
],
],
],
],
],
在我的 RbacManagerFactory 我这样称呼它:
$cache = $container->get('FilesystemCache');
我已经尝试在我的模块中配置 FilesystemService,如下所示:
'service_manager' => [
'factories' => [
\Zend\Cache\Storage\Adapter\FilesystemService::class => InvokableFactory::class,
],
],
但是没用
我还需要配置更多吗?
编辑 2018-10-29
当我尝试运行 sample 时,会出现以下错误:
[2018 年 10 月 29 日星期一 12:06:13.097747] [php7:warn] [pid 943] [client 127.0.0.1:48824] PHP 警告:file_put_contents(data/cache/module-config-cache.application.config. cache.php):无法打开流:第 65 行的 /var/www/html/roledemo/vendor/zendframework/zend-modulemanager/src/Listener/AbstractListener.php 中没有这样的文件或目录 [2018 年 10 月 29 日星期一 12:06:13.098593] [php7:warn] [pid 943] [client 127.0.0.1:48824] PHP 警告:file_put_contents(data/cache/module-classmap-cache.application.module.cache.php ):无法打开流:第 65 行的 /var/www/html/roledemo/vendor/zendframework/zend-modulemanager/src/Listener/AbstractListener.php 中没有这样的文件或目录 [Mon Oct 29 12:06:13.112886 2018] [php7:error] [pid 943] [client 127.0.0.1:48824] PHP 致命错误:方法 Zend\View\Helper\HeadTitle::__toString() 不得抛出异常,捕获 Zend\I18n\Exception\ExtensionNotLoadedException: Zend\I18n\Translator component requires the intl PHP extension in /var/www/html/roledemo/module/Application/view/layout/layout.phtml on line 0
我无法访问任何网址。
可能是我的 php 或 apache 版本?
【问题讨论】:
-
最近才自己设置。猜你一直在做this?你确定你已经安装了
zendframework/zend-cache和zendframework/zend-serializer吗?我尝试了同样的方法,它对我来说是开箱即用的。 -
@rkeet 是的,这就是我正在学习的教程。我已经安装了 zendframework/zend-cache 和 zendframework/zend-serializer。你的php版本是什么?它仍然无法在这里工作
标签: zend-framework3 zend-cache