CMS Framework - v2.2.2

Settings

The Settings module provides a lightweight, application‑wide key–value store with:

  • Declarative registration of settings (with defaults, types, and sanitization callbacks)
  • Simple helpers to retrieve and update values
  • Database persistence in a dedicated settings table
  • A filter hook so packages and modules can register settings from anywhere

Settings Guides

Overview

Settings are discovered via a filter and stored in the database. You register settings during boot, then read and write them anywhere in your app.

Quick Example

use function apRegisterSetting;
use function apGetSetting;
use function apUpdateSetting;

// Register during boot (e.g., a service provider)
apRegisterSetting(
    key: 'site.title',
    defaultValue: 'My Site',
    callback: fn ($value) => trim((string) $value),
    type: 'string'
);

// Retrieve (uses stored value, registered default, or explicit fallback)
$title = apGetSetting('site.title', 'Fallback Title');

// Update (value will be sanitized using the registered callback)
apUpdateSetting('site.title', '  New Title  ');

See the guides above for more details and patterns.