Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Site Configuration

Security covered Under active development 18 sites

Part of the Site ecosystem · 38 projects

This module offers a centralized system to define, manage, and access global site configurations. It automatically generates an administration interface for these configurations and can expose them through optional REST or JSON:API endpoints, making it suitable for decoupled Drupal sites.

Provides a centralized way to define, manage, and expose global site configuration in Drupal, with first-class support for decoupled or headless architectures.

This module allows developers to define structured configuration groups via plugins, automatically generates an administration UI, and exposes the stored values through services and optional API endpoints (REST and JSON:API).

Features

SiteConfig plugin type

This module introduces a new plugin type called SiteConfig, which allows you to define logical groups of configuration fields using annotations.

Each plugin represents a configuration set with:

  • A unique ID
  • A label and description
  • A list of fields with type, label, options, and validation
  • Optional storage and translation settings

Plugins must be created under:

src/Plugin/SiteConfig

Example SiteConfig plugin

Define the Plugin using PHP Attributes (Recommended)

namespace Drupal\your_module\Plugin\SiteConfig;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\site_config\Attribute\SiteConfig;
use Drupal\site_config\SiteConfigPluginBase;

#[SiteConfig(
  id: "custom_settings_attribute",
  label: new TranslatableMarkup("Custom Settings attribute"),
  fields: [
    "welcome_message" => [
      "type" => "textfield",
      "title" => "Welcome Message",
      "description" => "A message shown on the home page.",
    ],
    "featured_node" => [
      "type" => "entity_autocomplete",
      "target_type" => "node",
      "title" => "Featured Content",
    ],
  ],
  storage: "config",
  translatable: true,
)]
class YourPluginName extends SiteConfigPluginBase {
}
Define the Plugin using Annotations (Legacy)
namespace Drupal\site_config\Plugin\SiteConfig;

use Drupal\site_config\SiteConfigPluginBase;

/**
 * Plugin implementation of a SiteConfig.
 *
 * @SiteConfig(
 *   id = "foo",
 *   label = @Translation("Foo"),
 *   description = @Translation("Foo description."),
 *   fields = {
 *     "field_1" = {
 *       "label" = @Translation("Field 1"),
 *       "type" = "select",
 *       "options" = { 0 = "No", 1 = "Yes" },
 *       "required" = TRUE
 *     },
 *     "field_2" = {
 *       "label" = @Translation("Field 2")
 *     }
 *   },
 *   storage = "config",
 *   translatable = TRUE
 * )
 */
class Foo extends SiteConfigPluginBase {
}

Plugin options

  • storage (optional): determines where the values are stored.
    Possible values: state, config.
    Default: state
  • translatable (optional): enables translation support for configuration values.
    Default: FALSE
  • field type (optional): defaults to textfield if not specified.

Automatically generated admin form

The module provides an administration page at:

/admin/site-config

This form is generated automatically based on the defined SiteConfig plugins and handles storing and retrieving their values.


API submodules

The module includes two optional submodules to expose configuration values for decoupled frontends.

site_config_jsonapi

Provides JSON:API endpoints:

  • Get all site configs: /jsonapi/site-config
  • Get a specific config by ID: /jsonapi/site-config/item/{id}

site_config_rest

Provides REST endpoints:

  • Get all site configs: /api/site-config
  • Get a specific config by ID: /api/site-config/{id}

Services

The module defines the SiteConfigService, which allows programmatic access to configuration values:

 \Drupal::service('site_config.service')->getSiteConfig(); 

Returns all configuration values.

 \Drupal::service('site_config.service')->getSiteConfigById('foo'); 

Returns all values for a specific SiteConfig plugin.

 \Drupal::service('site_config.service')->getValue('foo', 'field_1'); 

Returns a single field value.

 \Drupal::service('site_config.service')->setValue('foo', 'field_1', 'value'); 

Sets a field value programmatically.

Drupal 10–11

Ask your assistant about Site Configuration

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • language Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
18
Tracked since
Nov 2023
Latest release
8 months ago
Releases (12 mo)
5 ▲ from 1
Maintenance
Slowing

Release Timeline

Releases

Version Type Core PHP Release date
1.0.1 Stable 10–11 Jan 30, 2026
1.0.0 Stable 10–11 Jan 27, 2026
1.0.0-rc10 Pre-release 10–11 Jan 20, 2026
1.0.0-rc9 Pre-release 10–11 Dec 26, 2025
1.0.0-rc8 Pre-release 9–11 Dec 19, 2025
1.0.0-rc7 Pre-release 9–10 Oct 24, 2024
1.0.0-rc6 Pre-release 9–10 Oct 11, 2024
1.0.0-rc5 Pre-release 9–10 Aug 27, 2024
1.0.0-rc4 Pre-release 9–10 Jul 12, 2024
1.0.0-rc3 Pre-release 9–10 Jan 15, 2024