tereta/config

Maintainers

Package info

gitlab.com/tereta/framework/config

Issues

pkg:composer/tereta/config

Statistics

Installs: 226

Dependents: 6

Suggesters: 0

Stars: 0

1.0.8 2026-05-05 09:48 UTC

This package is auto-updated.

Last update: 2026-05-18 20:01:04 UTC


README

๐ŸŒ ะ ัƒััะบะธะน | English

Installation

composer require tereta/config

Configuration layers

Values are resolved as a cascade, in priority order:

  1. In-memory layer โ€” values set from PHP code via Pool::set().
  2. Site-specific DB layer โ€” rows from the config table with site_id = {id} (only when get() is called with a $siteId).
  3. Global DB layer โ€” rows from the config table with site_id IS NULL.

DB rows are loaded lazily on the first get() call and cached in memory for the lifetime of the singleton.

In-memory layer

Values set directly from PHP code. Stored in memory on top of Tereta\Core\Data\Value and support dot-notation paths.

use Tereta\Config\Services\Pool;

Pool::singleton()->set('site.name', 'My Site');
Pool::singleton()->set(
    'site',
    ['name' => 'My Site']
);

$value = Pool::singleton()->get('site.name');

Note: programmatic set() calls should run during bootstrap โ€” before the first get(). After the DB layers are first loaded, subsequent set() calls are not reflected in the read cache.

Reading global DB configuration

Applies to all sites. Rows in the config table with site_id IS NULL.

use Tereta\Config\Services\Pool;

$value = Pool::singleton()->get('store.name');

Reading site-specific configuration

Returns the value for the given site; falls back to the global value when no site override exists.

use Tereta\Config\Services\Pool;

$value = Pool::singleton()->get('store.name', $siteId);

config table schema

FieldTypePurpose
idinteger (PK)Auto-increment
identifiervarchar(127)Configuration key (supports dot-notation)
valuetextValue
site_idinteger (FK)NULL for global, otherwise references site

Rows in the config table are created by external tooling (migrations, admin UI). This module exposes read-only access via Pool::get().