Skip to content

[6.x] Addons Settings + Control Panel page #11929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
Jul 23, 2025
Merged

[6.x] Addons Settings + Control Panel page #11929

merged 60 commits into from
Jul 23, 2025

Conversation

duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Jul 4, 2025

This pull request makes a bunch of changes to the Addons page in the Control Panel.

Addon Listing

Instead of being a not-very-good clone of the Marketplace, the addons index page will now simply list out your installed addons:

CleanShot 2025-07-09 at 11 49 50

Unlisted addons have moved to this page, and will no longer be listed on the "Updates" page.

Addon Settings

This PR also makes it possible for addons to create their own settings pages by providing a "settings blueprint".

Settings blueprints can either be defined in an addon's service provider, or they can live in resources/blueprints/settings.yaml where they'll be automatically picked up.

public function bootAddon()
{
    $this->registerSettingsBlueprint([
        'tabs' => [
            'main' => [
                'sections' => [
                    [
                        'display' => __('SEO Basics'),
                        'fields' => [
                            [
                                'handle' => 'website_name',
                                'field' => ['type' => 'text', 'display' => 'Website Name', 'validate' => 'required'],
                            ],
                            [
                                'handle' => 'google_webmaster_verification_code',
                                'field' => ['type' => 'text', 'display' => 'Google Webmaster Verification Code'],
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ]);
}

CleanShot 2025-07-09 at 11 54 43

Configuration values, like URLs or API Keys can be referenced in addon settings using Antlers: {{ config:app:url }}

Addons can then retrieve their settings via the Addon facade:

use Statamic\Facades\Addon;

$addon = Addon::get('vendor/package');

// Getting settings...
$addon->settings()->get('api_key');

$addon->settings()->all();
$addon->settings()->raw(); // Doesn't evaluate Antlers

// Setting values...
$addon->settings()->set('api_key', '{{ config:services:example:api_key }}');

$addon->settings()->set([
    'website_name' => 'My Awesome Site',
    'api_key' => '{{ config:services:example:api_key }}',
]);

// Saving...
$addon->settings()->save();

By default, addon settings will be stored in YAML files in resources/addons. However, they can easily moved into the database using php please install:eloquent-driver.

Permissions

We now have two sets of addon-related permissions:

  • Configure Addons
    • This permission already existed. It'll give you access to view the list of installed addons and edit any addon settings.
  • Edit {addon} settings
    • This is a new permission. It gives you access to the settings of a particular addon.
    • When you don't also have the "Configure Addons" permission, addon settings will be available via dedicated nav items, so you don't need to go through the index page.

What's the difference between addon settings & config files?

  • Addon Settings are intended to be settings that end-users should be able to touch. Things like SEO defaults or configuring sitemaps.
  • Config files are intended to hold settings that only a developer should be touching. Like anything that references classes, or is fundamental to the running of the app.

Related: statamic/docs#1699
Related: statamic/eloquent-driver#469

@ryanmitchell
Copy link
Contributor

Excited for this one, its a big time saver.

I've also added some handling around the situation where a repository's config array doesn't exist in the app's eloquent-driver.php.

When it's not present, it'll find the array from the Eloquent Driver's base config, and append it to the bottom of the app's eloquent config.
Going to move the database side in the Eloquent Driver, to keep things consistent with everything else.

It has the infrastructure (configs, import/export commands, migration helpers, etc) for handling database stuff.
@aerni
Copy link
Contributor

aerni commented Jul 8, 2025

Love to see this! Is it possible for the settings to be site-aware? This can be crucial for certain scenarios like SEO.

@duncanmcclean
Copy link
Member Author

Is it possible for the settings to be site-aware? This can be crucial for certain scenarios like SEO.

We're not planning on making addon settings localisable I'm afraid, at least not right now. It would complicate things for the vast majority of addons who don't need site-specific settings.

However, what you could do is create a custom publish form (we've simplified them in #11787) w/ the localizable fields, then use the flat file/database storage stuff provided by this PR.

@aerni
Copy link
Contributor

aerni commented Jul 8, 2025

I understand.

However, what you could do is create a custom publish form (we've simplified them in #11787) w/ the localizable fields, then use the flat file/database storage stuff provided by this PR.

What "flat file/database storage stuff" are you referring to?

@duncanmcclean
Copy link
Member Author

What "flat file/database storage stuff" are you referring to?

By default, addon settings will be stored as YAML files in resources/addons, but you'll be able to move them into the database with php please install:eloquent-driver.

So, if you need to build your own publish form, you could still use the flat file/database storage layer using the helpers provided by this PR, saving you from needing to build that part yourself.

@jackmcdade jackmcdade changed the title [6.x] Control Panel Addons page [6.x] Addons Settings + Control Panel page Jul 8, 2025
@jasonvarga jasonvarga merged commit d8c22cb into master Jul 23, 2025
19 checks passed
@jasonvarga jasonvarga deleted the addons branch July 23, 2025 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy