Skip to content

Options

Viames Marino edited this page Feb 23, 2026 · 1 revision

Pair framework: Options

Pair\Helpers\Options manages application options stored in database table options.

It is a singleton with typed casting and optional password encryption.

Main methods

Options::get(string $name): mixed

Returns one option value.

Options::set(string $name, mixed $value): bool

Updates one option value in DB and in-memory cache.

Options::exists(string $name): bool

Options::getInstance(): Options

getAll(): array

refresh(): void

Encryption behavior

Password-type options can be encrypted/decrypted using OPTIONS_CRYPT_KEY from .env.

Helper:

  • isCryptAvailable(): bool

Implementation example

use Pair\Helpers\Options;

$siteName = Options::get('site_name');

if (Options::exists('smtp_password')) {
    Options::set('smtp_password', 'new-secret');
}

$all = Options::getInstance()->getAll();

Notes

  • Missing option names throw PairException on set.
  • Option values are cast according to their configured type (int, bool, password, ...).

See also: Database, Configuration-file, Mailer.

Clone this wiki locally