zend-framework3 - ZF3 zend-cache 错误无法将服务“FilesystemCache”解析为工厂
问题描述
我正在尝试将 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
当我尝试运行示例时,它会出现此错误:
[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 中没有这样的文件或目录 [Mon Oct 29 12:06:13.098593 2018 ] [php7:warn] [pid 943] [client 127.0.0.1:48824] PHP 警告:file_put_contents(data/cache/module-classmap-cache.application.module.cache.php):打开流失败:没有这样的文件或 /var/www/html/roledemo/vendor/zendframework/zend-modulemanager/src/Listener/AbstractListener.php 中的目录 [2018 年 10 月 29 日星期一 12:06:13.112886] [php7:error] [pid 943] [client 127.0.0.1:48824] PHP 致命错误:方法 Zend\View\Helper\HeadTitle::__toString() 不得抛出异常,捕获 Zend\I18n\Exception\ExtensionNotLoadedException: Zend\I18n\Translator 组件需要 intl PHP extension in /var/www/html/roledemo/module/Application/view/layout/layout.phtml 在第 0 行
而且我无法访问任何 URL。
会不会是我的 php 或 apache 版本?
解决方案
所以我错过了一些东西,这就是为什么它以前不起作用:
- 创建数据/缓存文件夹并授予其权限 775
- 创建 public/img/captcha 文件夹并授予权限 775
- 添加模块 Zend\Serializer 和 Zend\Cache 到 config/modules.config.php
添加
'rbac_manager' => ['assertions' => [Service\RbacAssertionManager::class], ],
到模块/登录/配置/module.config.php
- 而且,如果您按照文本进行操作,而不是下载代码:在 src/Service/RbacManager.php 第 72 行中将 $result 设置为 false
推荐阅读
- html - 带有可调节多列的角度下拉菜单
- java - 找不到符号 Menu 和 MenuItem
- r - 如何使用原始数据框中的列名和行名将矩阵转换为数据框
- javascript - 对象索引未达到预期的数组
- android - android 发布版本上的 react-native-firebase NullPointerException
- json - 如何将 sqlite 数据库中的数据传递给模板?(使用highcharts制作折线图)
- python - 如何在 python 中绘制两个选定列与时间的分组条形图。我将在下面发布我的数据
- python - 无法使用 Python 将成功登录会话 cookie 传递到类方法中
- java - com4j 在 Eclipse 中工作,但在 jar 中不工作
- sql - 查找库存差异的开始和结束日期