Configuration must contain a "adapter" key in Laminas Framework

545 Views Asked by At

recién actualice el modulo laminas/laminas-cache a la versión ^3.1.3 y al momento de ejecutar mi desarrollo me lanza el siguiente error:

Fatal error: Uncaught InvalidArgumentException: Configuration must contain a "adapter" key. in C:\xampp\htdocs\bisef\vendor\laminas\laminas-cache\src\Service\StorageAdapterFactory.php:85

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

There are 1 best solutions below

0
On

as said by the error message, the adapter key is missing. The correct configuration should the following:

'caches' => [
    'adapter' => \Laminas\Cache\Storage\Adapter\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' => []
        ]
    ]
],

In case you are using multiple caches and you need to separate them (as shown by your snippet), then:

'caches' => [
    'FilesystemCache' => [
        'adapter' => \Laminas\Cache\Storage\Adapter\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' => []
            ]
        ]
    ]
]