# Clear-config-cache error with new Mezzo install

**URL:** <https://discourse.laminas.dev/t/clear-config-cache-error-with-new-mezzo-install/3820>\
**Category:** Mezzio\
**Created:** [December 16, 2024, 10:39am UTC](https://discourse.laminas.dev/t/clear-config-cache-error-with-new-mezzo-install/3820 "2024-12-16T10:39:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tompin](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@tompin](https://discourse.laminas.dev/u/tompin)\
**Post date:** [December 16, 2024, 10:39am UTC](https://discourse.laminas.dev/t/clear-config-cache-error-with-new-mezzo-install/3820/1 "2024-12-16T10:39:49Z")

</div>

Hello,

I’m getting the following error on a new Mezzo install. On macOS using home-brew - I have tried with PHP 8.3 and 8.4.

Does anyone have an idea of the cause, please?

Tom

```auto
php bin/clear-config-cache.php

PHP Fatal error: Uncaught Laminas\ConfigAggregator\InvalidConfigProviderException: Mezzio\Helper\ConfigProvider is registered more than once. Config providers should be unique. In case a specific order is required, please double check before deleting the duplicate(s). in /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php:15

Stack trace:

#0 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(117): Laminas\ConfigAggregator\InvalidConfigProviderException::fromDuplicateProvider('Mezzio\\Helper\\C...')

#1 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(85): Laminas\ConfigAggregator\ConfigAggregator->validateNoDuplicateProviders(Array)

#2 /Users/tom/Sites/mezzio/config/config.php(16): Laminas\ConfigAggregator\ConfigAggregator->__construct(Array, 'data/cache/conf...')

#3 /Users/tom/Sites/mezzio/bin/clear-config-cache.php(9): include('/Users/tom/Site...')

#4 {main}

thrown in /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php on line 15

Fatal error: Uncaught Laminas\ConfigAggregator\InvalidConfigProviderException: Mezzio\Helper\ConfigProvider is registered more than once. Config providers should be unique. In case a specific order is required, please double check before deleting the duplicate(s). in /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php:15

Stack trace:

#0 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(117): Laminas\ConfigAggregator\InvalidConfigProviderException::fromDuplicateProvider('Mezzio\\Helper\\C...')

#1 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(85): Laminas\ConfigAggregator\ConfigAggregator->validateNoDuplicateProviders(Array)

#2 /Users/tom/Sites/mezzio/config/config.php(16): Laminas\ConfigAggregator\ConfigAggregator->__construct(Array, 'data/cache/conf...')

#3 /Users/tom/Sites/mezzio/bin/clear-config-cache.php(9): include('/Users/tom/Site...')

#4 {main}

thrown in /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php on line 15

Script php bin/clear-config-cache.php handling the clear-config-cache event returned with error code 255

Script @clear-config-cache was called via post-update-cmd

```

Install command and mezzio-skeleton version (3.15.0):

```auto
tom@tmbp sites % composer create-project mezzio/mezzio-skeleton mezzio

Creating a "mezzio/mezzio-skeleton" project at "./mezzio"

Installing mezzio/mezzio-skeleton (3.15.0)

- Installing mezzio/mezzio-skeleton (3.15.0): Extracting archive

Created project in /Users/tom/Sites/mezzio

> MezzioInstaller\OptionalPackages::install

Setting up optional packages

Setup data and cache dir

Removing installer development dependencies

```

---

<div class="post-metadata">

**Author:** ![Tyrsson](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/tyrsson/32/1664_2.png) [@Tyrsson](https://discourse.laminas.dev/u/Tyrsson)\
**Post date:** [December 16, 2024, 4:51pm UTC](https://discourse.laminas.dev/t/clear-config-cache-error-with-new-mezzo-install/3820/2 "2024-12-16T16:51:44Z")

</div>

At the top of the file you will see a use statement for Mezzio\Helper\ConfigProvider. Just remove it and its reference in the array. ConfigAggregator now checks to verify that each ConfigProvider is only registered once.

So to recap.

1 Remove the helper use statement.  
2 Remove the entry in the array that references it, its the only ConfigProvider::class entry.

Let us know it that fixes it.

---

<div class="post-metadata">

**Author:** ![tompin](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@tompin](https://discourse.laminas.dev/u/tompin)\
**Post date:** [December 17, 2024, 3:27pm UTC](https://discourse.laminas.dev/t/clear-config-cache-error-with-new-mezzo-install/3820/3 "2024-12-17T15:27:42Z")

</div>

Thank you for the reply, Tyrsson.

I wasn’t sure which file I should be modifying, so I searched the new Mezzo folder for “Mezzio\Helper\ConfigProvider” and the only occurrence was in the /config/config.php file - so I commented out line 8 and 19 as per below:

```auto
<?php

declare(strict_types=1);

use Laminas\ConfigAggregator\ArrayProvider;
use Laminas\ConfigAggregator\ConfigAggregator;
use Laminas\ConfigAggregator\PhpFileProvider;
//use Mezzio\Helper\ConfigProvider;

// To enable or disable caching, set the `ConfigAggregator::ENABLE_CACHE` boolean in
// `config/autoload/local.php`.
$cacheConfig = [
    'config_cache_path' => 'data/cache/config-cache.php',
];

$aggregator = new ConfigAggregator([
    \Mezzio\Tooling\ConfigProvider::class,
    \Mezzio\LaminasView\ConfigProvider::class,
  // \Mezzio\Helper\ConfigProvider::class,
    \Mezzio\Router\FastRouteRouter\ConfigProvider::class,
    \Laminas\HttpHandlerRunner\ConfigProvider::class,
    // Include cache configuration
    new ArrayProvider($cacheConfig),
    ConfigProvider::class,
    \Mezzio\ConfigProvider::class,
    \Mezzio\Router\ConfigProvider::class,
    \Laminas\Diactoros\ConfigProvider::class,

    // Swoole config to overwrite some services (if installed)
    class_exists(\Mezzio\Swoole\ConfigProvider::class)
        ? \Mezzio\Swoole\ConfigProvider::class
        : function (): array {
            return [];
        },

    // Default App module config
    App\ConfigProvider::class,

    // Load application config in a pre-defined order in such a way that local settings
    // overwrite global settings. (Loaded as first to last):
    // - `global.php`
    // - `*.global.php`
    // - `local.php`
    // - `*.local.php`
    new PhpFileProvider(realpath( __DIR__ ) . '/autoload/{{,*.}global,{,*.}local}.php'),

    // Load development config if it exists
    new PhpFileProvider(realpath( __DIR__ ) . '/development.config.php'),
], $cacheConfig['config_cache_path']);

return $aggregator->getMergedConfig();

```

Which now causes different error messages when, for example, trying to composer update:

```auto
> php bin/clear-config-cache.php

PHP Fatal error: Uncaught Laminas\ConfigAggregator\InvalidConfigProviderException: Cannot read config from ConfigProvider - class cannot be loaded. in /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php:28

Stack trace:

#0 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(146): Laminas\ConfigAggregator\InvalidConfigProviderException::fromNamedProvider('ConfigProvider')

#1 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(260): Laminas\ConfigAggregator\ConfigAggregator->resolveProvider('ConfigProvider')

#2 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(86): Laminas\ConfigAggregator\ConfigAggregator->loadConfigFromProviders(Array)

#3 /Users/tom/Sites/mezzio/config/config.php(16): Laminas\ConfigAggregator\ConfigAggregator->__construct(Array, 'data/cache/conf...')

#4 /Users/tom/Sites/mezzio/bin/clear-config-cache.php(9): include('/Users/tom/Site...')

#5 {main}

thrown in /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php on line 28

Fatal error: Uncaught Laminas\ConfigAggregator\InvalidConfigProviderException: Cannot read config from ConfigProvider - class cannot be loaded. in /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php:28

Stack trace:

#0 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(146): Laminas\ConfigAggregator\InvalidConfigProviderException::fromNamedProvider('ConfigProvider')

#1 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(260): Laminas\ConfigAggregator\ConfigAggregator->resolveProvider('ConfigProvider')

#2 /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(86): Laminas\ConfigAggregator\ConfigAggregator->loadConfigFromProviders(Array)

#3 /Users/tom/Sites/mezzio/config/config.php(16): Laminas\ConfigAggregator\ConfigAggregator->__construct(Array, 'data/cache/conf...')

#4 /Users/tom/Sites/mezzio/bin/clear-config-cache.php(9): include('/Users/tom/Site...')

#5 {main}

thrown in /Users/tom/Sites/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php on line 28

Script php bin/clear-config-cache.php handling the clear-config-cache event returned with error code 255

Script @clear-config-cache was called via post-update-cmd

tom@tmbp mezzio %

```

---

<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:** [December 17, 2024, 7:58pm UTC](https://discourse.laminas.dev/t/clear-config-cache-error-with-new-mezzo-install/3820/4 "2024-12-17T19:58:59Z")

</div>

Typical namespace problem. You cannot comment out the following line if it is used later.

> [@tompin](#):
>
> ```auto
> //use Mezzio\Helper\ConfigProvider;
> 
> ```

> [@tompin](#):
>
> ```auto
> ConfigProvider::class,
> 
> ```

Another variant:

```auto
use Laminas\ConfigAggregator\ArrayProvider;
use Laminas\ConfigAggregator\ConfigAggregator;
use Laminas\ConfigAggregator\PhpFileProvider;

$aggregator = new ConfigAggregator([
    \Mezzio\Tooling\ConfigProvider::class,
    \Mezzio\LaminasView\ConfigProvider::class,
    \Mezzio\Helper\ConfigProvider::class,
    \Mezzio\Router\FastRouteRouter\ConfigProvider::class,
    \Laminas\HttpHandlerRunner\ConfigProvider::class,
    // Include cache configuration
    new ArrayProvider($cacheConfig),
    \Mezzio\ConfigProvider::class,
    \Mezzio\Router\ConfigProvider::class,
    \Laminas\Diactoros\ConfigProvider::class,

    // …

```
