# Laminas filesystem cache usage

**URL:** <https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440>\
**Category:** Components & MVC\
**Tags:** laminas-cache\
**Created:** [August 16, 2023, 9:58am UTC](https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440 "2023-08-16T09:58:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aleksandr\_Zamiatin](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/aleksandr_zamiatin/32/1563_2.png) [@Aleksandr\_Zamiatin](https://discourse.laminas.dev/u/Aleksandr_Zamiatin)\
**Post date:** [August 16, 2023, 9:58am UTC](https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440/1 "2023-08-16T09:58:57Z")

</div>

Greetings, I’m trying to use file cache in my app. Steps I’m doing:

- `require laminas/laminas-cache-storage-adapter-filesystem `
- adding section to my autoload/cache.global.php:

```auto
'filesystem' => [
            'name' => 'filesystem',
            'options' => [
                'cache_dir' => __DIR__. '/../../data/cache',
            ],
            'plugins' => [
                [
                    'name' => 'serializer',
                    'options' => [
                    ],
                ],
            ],
        ],

```

- in confg.php I’m including ConfigProvider:

```auto
$aggregator = new ConfigAggregator([
...
    \Laminas\Cache\Storage\Adapter\Filesystem\ConfigProvider::class,
...

```

and getting error:

```auto
[16-Aug-2023 09:57:49 UTC] PHP Fatal error: Uncaught Laminas\ConfigAggregator\InvalidConfigProviderException: Cannot read config from Laminas\Cache\Storage\Adapter\Filesystem\ConfigProvider - class cannot be loaded. in /var/www/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php:19

Stack trace:
#0 /var/www/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(113): Laminas\ConfigAggregator\InvalidConfigProviderException::fromNamedProvider()
#1 /var/www/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(230): Laminas\ConfigAggregator\ConfigAggregator->resolveProvider()
#2 /var/www/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(82): Laminas\ConfigAggregator\ConfigAggregator->loadConfigFromProviders()
#3 /var/www/config/config.php(62): Laminas\ConfigAggregator\ConfigAggregator->__construct()
#4 /var/www/config/container.php(8): require('...')
#5 /var/www/public/index.php(18): require('...')
#6 /var/www/public/index.php(30): {closure}()

```

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [August 16, 2023, 10:05am UTC](https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440/2 "2023-08-16T10:05:05Z")

</div>

Hello and welcome to our forums! 😃

It looks like you do not use the automated configuration via the component installer; see:

> **[Installation - laminas-cache - Laminas Docs](https://docs.laminas.dev/laminas-cache/v3/installation/#installation-for-mezzio-and-laminas-mvc-application)**
>
> Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output.

> [@Aleksandr\_Zamiatin](#):
>
> - in confg.php I’m adding section for cache:
> 
> ```auto
> 'filesystem' => [
> 'name' => 'filesystem',
> 'options' => [
> 'cache_dir' => __DIR__. '/../../data/cache',
> ],
> ],
> 
> ```

This makes no sense because it is a duplication and not needed. Check the related tutorial:

> **[Usage in a laminas-mvc Application - laminas-cache - Laminas Docs](https://docs.laminas.dev/laminas-cache/v3/application-integration/usage-in-a-laminas-mvc-application/)**
>
> Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output.

---

<div class="post-metadata">

**Author:** ![Aleksandr\_Zamiatin](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/aleksandr_zamiatin/32/1563_2.png) [@Aleksandr\_Zamiatin](https://discourse.laminas.dev/u/Aleksandr_Zamiatin)\
**Post date:** [August 16, 2023, 10:07am UTC](https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440/3 "2023-08-16T10:07:04Z")

</div>

My bad, pasted wrong part, edited already 😀

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [August 16, 2023, 10:19am UTC](https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440/4 "2023-08-16T10:19:38Z")

</div>

Do you use laminas-mvc or Mezzio?

---

<div class="post-metadata">

**Author:** ![Aleksandr\_Zamiatin](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/aleksandr_zamiatin/32/1563_2.png) [@Aleksandr\_Zamiatin](https://discourse.laminas.dev/u/Aleksandr_Zamiatin)\
**Post date:** [August 16, 2023, 10:28am UTC](https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440/5 "2023-08-16T10:28:09Z")

</div>

I’m using Mezzio.

So I don’t understand why I’m getting error after adding `\Laminas\Cache\Storage\Adapter\Filesystem\ConfigProvider::class` to ConfigAggregator  
but before that I already used `\Laminas\Cache\Storage\Adapter\Redis\ConfigProvider::class` and did’t get any errors.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [August 16, 2023, 12:10pm UTC](https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440/6 "2023-08-16T12:10:19Z")

</div>

The name of the class looks good.  
Please recheck that the folder with `laminas/laminas-cache-storage-adapter-filesystem` is present in the `vendor` directory of your application.

---

<div class="post-metadata">

**Author:** ![Aleksandr\_Zamiatin](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/aleksandr_zamiatin/32/1563_2.png) [@Aleksandr\_Zamiatin](https://discourse.laminas.dev/u/Aleksandr_Zamiatin)\
**Post date:** [August 18, 2023, 10:27am UTC](https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440/7 "2023-08-18T10:27:03Z")

</div>

Seems the problem was with the composer. Thanks.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [August 18, 2023, 4:37pm UTC](https://discourse.laminas.dev/t/laminas-filesystem-cache-usage/3440/8 "2023-08-18T16:37:35Z")

</div>

Thank you for the feedback. 👍
