Configuration must contain a "adapter" key in StorageAdapterFactory.php

Al momento de actualiza laminas/laminas-cache a la versión ^3.1.3 me arrojado el siguiente error:

**Fatal error**: Uncaught InvalidArgumentException: Configuration must contain a "adapter" key. in StorageAdapterFactory.php

Mi configuración en global.php es la siguiente:

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

En versiones anteriores esta configuración me funcionaba correctamente pero ahora no, alguna solución??

Please rewrite your post in English, otherwise not everyone will understand your question.
Thanks in advance! :+1:t3:

I found this post and having same issue, so let me carry on. This application built with ZF3 and migrated to Laminas already. And now we have to make it to work on PHP8. Originally we had config like this


'caches' => [
        'FilesystemCache' => [
            'adapter' => [
                'name'    => Filesystem::class,
                'options' => [
                    // Store cached data in this directory.
                    'cache_dir' => './data/cache',
                    'ttl' => 100
                ],
            ],
            'plugins' => [
                [
                    'name' => 'serializer',
                    'options' => [
                    ],
                ],
            ],
        ],
    ],

Then, having " Configuration must contain a adapter key" error, changed config like below,

'caches' => [
        'FilesystemCache' => [
            'adapter' => \Laminas\Cache\Storage\Adapter\Filesystem::class,
            'options' => [
                // Store cached data in this directory.
                'cache_dir' => './data/cache',
                'ttl' => 60*60*1
            ],
            'plugins' => [
                [
                    'name' => 'serializer',
                    'options' => [
                    ],
                ],
            ],
        ],
    ],

now I get error says
‘Unable to resolve service “Laminas\Cache\Storage\Adapter\Filesystem” to a factory; are you certain you provided it during configuration?’
and don’t know how to add Filesystem Factory since there is no factory file provided.

Please someone give us advice. Thanks!!

Hello and welcome to our forums! :smiley:

These are the correct changes for version 3 of laminas-cache.

See documentation:

Migration guide:

Or release notes:

Have you installed the storage adapter? Since version 3 of laminas-cache all storage adapters are optional, so you can choose for yourself what is really needed for your application. No more installation of adapters you don’t need or blocking because of missing system requirements.

Run installation for laminas-cache-storage-adapter-filesystem:

composer require laminas/laminas-cache-storage-adapter-filesystem

The biggest change with laminas-cache v3.0 is that this component will be shipped without a specific cache adapter. The idea behind this is, that projects can freely choose those cache adapters they really use.

2 Likes

Thank you so much for opening up my eyes!! I haven’t installed laminas-cache-storage-adapter-filesystem, and I did it, it works fine now!! You save my days!!

1 Like