zend-framework3zend-cache

ZF3 zend-cache error Unable to resolve service "FilesystemCache" to a factory


I'm trying to use zend-cache with zend-rbac.

zend-rbac is ok, but when I try to add zend-cache I got this message:

Unable to resolve service "FilesystemCache" to a factory; are you certain you provided it during configuration?

My cache configuration at global.php is like this:

// 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' => [                        
                ],
            ],
        ],
    ],
],

And in my RbacManagerFactory I'm calling it like this:

$cache = $container->get('FilesystemCache');

I already try to config FilesystemService in my module, like this:

'service_manager' => [
    'factories' => [
        \Zend\Cache\Storage\Adapter\FilesystemService::class => InvokableFactory::class,
    ],
],

But it didn't work

Do I need to config something more?

EDIT 2018-10-29

When I try to run the sample it gives this error:

[Mon Oct 29 12:06:13.097747 2018] [php7:warn] [pid 943] [client 127.0.0.1:48824] PHP Warning:  file_put_contents(data/cache/module-config-cache.application.config.cache.php): failed to open stream: No such file or directory in /var/www/html/roledemo/vendor/zendframework/zend-modulemanager/src/Listener/AbstractListener.php on line 65
[Mon Oct 29 12:06:13.098593 2018] [php7:warn] [pid 943] [client 127.0.0.1:48824] PHP Warning:  file_put_contents(data/cache/module-classmap-cache.application.module.cache.php): failed to open stream: No such file or directory in /var/www/html/roledemo/vendor/zendframework/zend-modulemanager/src/Listener/AbstractListener.php on line 65
[Mon Oct 29 12:06:13.112886 2018] [php7:error] [pid 943] [client 127.0.0.1:48824] PHP Fatal error:  Method Zend\\View\\Helper\\HeadTitle::__toString() must not throw an exception, caught 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

and I can't access any URL.

Could it be my php or apache version?


Solution

  • So I was missing some things, that's why it didn't work before:

        'rbac_manager' => [
            'assertions' => [Service\RbacAssertionManager::class],
        ],