NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Options for Laravel

Configuration

The published config/options.php in full:

return [
    'model' => RoundlyConsulting\Options\Option::class,

    // Owner key type: bigint, uuid or ulid — fixed when the migration first runs.
    'key_type' => env('OPTIONS_KEY_TYPE', 'bigint'),

    'registry' => [
        // 'theme' => App\Options\ThemeOption::class,
    ],

    'cache' => [
        'enabled' => env('OPTIONS_CACHE_ENABLED', true),
        'store'   => env('OPTIONS_CACHE_STORE'),
        'ttl'     => env('OPTIONS_CACHE_TTL', 3600),
        'prefix'  => env('OPTIONS_CACHE_PREFIX', 'options'),
        'tag'     => env('OPTIONS_CACHE_TAG', 'options'),
    ],

    'events' => [
        'enabled'  => env('OPTIONS_EVENTS_ENABLED', true),
        'resolved' => env('OPTIONS_EVENTS_RESOLVED', false),
    ],

    'groups' => [
        // 'billing' => App\Settings\BillingSettings::class,
    ],

    'authorization' => [
        'enabled'  => env('OPTIONS_AUTHORIZATION', false),
        'use_gate' => env('OPTIONS_AUTHORIZATION_GATE', false),
    ],

    'config_overrides' => [
        // 'mail.from.address' => App\Options\MailFromAddressOption::class,
    ],

    'config_overrides_live' => env('OPTIONS_CONFIG_OVERRIDES_LIVE', false),
];

Every key

KeyDefaultEnvPurpose
modelOption::class—Eloquent model that stores values. Must be RoundlyConsulting\Options\Option or a subclass of it; anything else throws.
key_typebigintOPTIONS_KEY_TYPEOwner key type — bigint, uuid or ulid (case-insensitive). Types owner_id; set it before you migrate. Anything else throws InvalidConfigurationException when the migration runs.
registry[]—Short string keys → option classes, for key-based access.
cache.enabledtrueOPTIONS_CACHE_ENABLEDEnable the persistent (cross-request) cache layer.
cache.storenullOPTIONS_CACHE_STORECache store name; null or blank (not set) uses the default store. A non-string value throws.
cache.ttl3600OPTIONS_CACHE_TTLLifetime in seconds — a whole number, at least 1; null caches forever, blank (OPTIONS_CACHE_TTL=) is not set and gives 3600. Junk such as abc or 0 throws instead of silently disabling the cache.
cache.prefixoptionsOPTIONS_CACHE_PREFIXCache key prefix. A blank value is not set and uses the default; a non-string value throws.
cache.tagoptionsOPTIONS_CACHE_TAGCache tag, so a taggable store (Redis, Memcached) also purges old entries on a flush. A blank value is not set and uses the default; a non-string value throws.
events.enabledtrueOPTIONS_EVENTS_ENABLEDDispatch OptionSet / OptionForgotten. Observers and live config overrides ride on these.
events.resolvedfalseOPTIONS_EVENTS_RESOLVEDAlso dispatch OptionResolved on every read — chatty, so off by default.
groups[]—Short keys → OptionGroup classes, for Options::group('key').
authorization.enabledfalseOPTIONS_AUTHORIZATIONEnforce per-option authorizeRead() / authorizeWrite() hooks.
authorization.use_gatefalseOPTIONS_AUTHORIZATION_GATEAlso consult the option.read / option.write Gate abilities when defined.
config_overrides[]—config() keys → options whose stored value overrides config at boot.
config_overrides_livefalseOPTIONS_CONFIG_OVERRIDES_LIVERe-apply a mapped config key in-process on set() / forget().

Environment

Everything except the model and the class maps is env-backed, so most deployments never publish the config:

OPTIONS_KEY_TYPE=bigint
OPTIONS_CACHE_ENABLED=true
OPTIONS_CACHE_STORE=redis
OPTIONS_CACHE_TTL=3600
OPTIONS_CACHE_PREFIX=options
OPTIONS_CACHE_TAG=options
OPTIONS_EVENTS_ENABLED=true
OPTIONS_EVENTS_RESOLVED=false
OPTIONS_AUTHORIZATION=false
OPTIONS_AUTHORIZATION_GATE=false
OPTIONS_CONFIG_OVERRIDES_LIVE=false

The bool switches accept the usual env spellings: true / false, 1 / 0, on / off and yes / no. Every setting is read strictly: a key that is not set — absent, null or blank (a host’s KEY=) — takes its default, and any other invalid value throws InvalidConfigurationException naming the key instead of falling back.

About command

The package reports its configuration to Laravel’s about command. Option keys, group keys and bridged config paths are shown as counts only — a key names one of your settings and its value can be a token, a feature flag or personal data, so neither is ever printed:

php artisan about --only=options

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.