Confusion about Sage 10 Service Providers

I’m somewhat confused about how Service Providers are supposed to work in Sage 10. I cloned a fresh Sage 10 repo as a new theme into my Bedrock project. There I found a “providers” config in composer.json.

"extra": {
  "acorn": {
    "providers": [
      "App\\Providers\\ThemeserviceProvider"
    ]
  }
}

However, my default ThemeServiceProvider doesn’t seem to do anything. Not even when I break the PHP inside this file.

From a previous project I remember that Providers needed to be added to a config/app.php file. However, this this config directory seems to be completely missing from my cloned Sage 10 repo.

Can anyone shed some light on how this is supposed to work?

Take a look here about the config directory:

This confuses me, too. Just updated an older Sage 10 theme to the new structure and latest changes. However as I added the following to composer.json, but it does not seem to get recognized:

"extra": {
    "acorn": {
      "providers": [
        "Log1x\\SageSvg\\SageSvgServiceProvider",
        "App\\Providers\\LocalWebFontsServiceProvider",
        "App\\Providers\\CookiesConsentServiceProvider"
      ]
    }
  }

The link provided by @Davide_Prevosto does not bring light into the dark so a hint would be great what we are missing here.

Thanks!

1 Like

When it comes to service providers, Acorn v2 treats the theme as a package now. Packages contain service providers, which can be declared in composer.json.

Try clearing provider cache:

wp acorn clear-compiled

Or clear all caches with:

wp acorn optimize:clear

Also, you don’t need to add the one for SageSvg since it adds its own.

2 Likes

Thanks @QWp6t. It seems to be fixed with acorn 2.0.3 now.