---
title: "Options for Laravel — docs | Roundly"
description: "Developer docs for Options for Laravel: typed global and per-owner settings, encryption, caching, setting groups, access control and the config bridge."
url: https://roundly-consulting.com/open-source/docs/options-for-laravel
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

Open source

# Options for Laravel

Install

`composer require roundly-consulting/options-for-laravel`

Requires: PHP ^8.4 · Laravel ^12.0|^13.0

[GitHub](https://github.com/roundly-consulting/options-for-laravel) [Packagist](https://packagist.org/packages/roundly-consulting/options-for-laravel) [Donate (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Patreon](https://www.patreon.com/cw/roundly)

## Overview

A native settings layer for Laravel. Each option is a small class that declares its key, default and cast — and, when you need them, encryption, validation and access rules. Values live in one options table, either global or scoped to any Eloquent model: a user, a team, a tenant. Reads are memoised for the current request or queued job and optionally cached across requests, writes keep both layers in step and fire events, and a config bridge lets stored values override config() at boot. MIT-licensed and built on Laravel alone, plus Roundly’s own package toolkit.

### What you get

#### Global or per-owner

One options table for app-wide values and values scoped to any Eloquent model — users, teams, tenants.

#### Typed casts & encryption

Any Laravel cast, a custom CastsAttributes, a backed-enum cast, and at-rest encryption per option.

#### Two-layer caching

A per-request memo plus an optional persistent cache that flushes on any store. Both hold the raw stored value, and writes keep them in step.

#### Settings-screen groups

Bundle options into groups whose definition() hands your UI labels, help text, sections, order, types and current values.

#### Opt-in access control

Per-option read/write hooks, optional Gate abilities, actingAs() and withoutAuthorization() — off until you enable it.

#### Config bridge, events & CLI

Stored options override config() without a redeploy. OptionSet and OptionForgotten events, targeted observers and eight Artisan commands.

#### Facade, DI or actions

Use the Options facade, inject OptionsManager or call the export and import actions — Options::fake() records every write, whichever path made it.

### Documentation

#### [Installation](https://roundly-consulting.com/open-source/docs/options-for-laravel/installation.md)

Install via Composer, publish and run the options table migration, and optionally publish the config to edit the registry or swap the model.

#### [Configuration](https://roundly-consulting.com/open-source/docs/options-for-laravel/configuration.md)

Every config key and its default — model, owner key type, registry, cache, events, groups, authorization and the config bridge.

#### [Database schema & key type](https://roundly-consulting.com/open-source/docs/options-for-laravel/database-schema.md)

The single options table, how key\_type types the owner columns for bigint, UUID or ULID owners, and swapping in your own model.

#### [Defining options](https://roundly-consulting.com/open-source/docs/options-for-laravel/defining-options.md)

Extend BaseOption to declare an option’s key, default, cast, encryption, rules and presentation — or scaffold one with make:option.

#### [The Options facade](https://roundly-consulting.com/open-source/docs/options-for-laravel/facade.md)

The full Options facade surface — flat verbs, for(), option(), key() and group() handles, registry, observers, access control and cache.

#### [DI and actions](https://roundly-consulting.com/open-source/docs/options-for-laravel/without-facade.md)

Skip the facade: inject OptionsManager for the same API without static calls, or call the export and import actions directly.

#### [Reading & writing](https://roundly-consulting.com/open-source/docs/options-for-laravel/reading-writing.md)

Get, set, check, forget and remember option values through the Options facade — globally or scoped to an owner.

#### [Fluent API & bulk operations](https://roundly-consulting.com/open-source/docs/options-for-laravel/fluent-api.md)

Chain calls on a single option, scope a batch to an owner with for(), and read or write many options in one go.

#### [Owners & the HasOptions trait](https://roundly-consulting.com/open-source/docs/options-for-laravel/owner-scopes.md)

Scope values to any Eloquent model — users, teams, tenants — and read them straight off the model with the HasOptions trait.

#### [Helpers, registry & Blade](https://roundly-consulting.com/open-source/docs/options-for-laravel/helpers-registry.md)

The options() and setting() helpers, short string keys through the registry, and the escaped @option Blade directive.

#### [Casts & encryption](https://roundly-consulting.com/open-source/docs/options-for-laravel/casts-encryption.md)

Cast values with any Laravel cast, a custom CastsAttributes or the backed-enum cast, and encrypt sensitive options at rest.

#### [Validation](https://roundly-consulting.com/open-source/docs/options-for-laravel/validation.md)

Return Laravel validation rules from rules() and every write is validated before it’s cast or stored.

#### [Events](https://roundly-consulting.com/open-source/docs/options-for-laravel/events.md)

OptionSet, OptionForgotten and the opt-in OptionResolved — what each carries, when it fires and how to switch them off.

#### [Observers](https://roundly-consulting.com/open-source/docs/options-for-laravel/observers.md)

React to one specific option changing — closures or invokable classes, fired on set and forget in registration order.

#### [Setting groups](https://roundly-consulting.com/open-source/docs/options-for-laravel/setting-groups.md)

Bundle related options into a group that reads, writes and describes a whole settings screen in one call.

#### [Access control](https://roundly-consulting.com/open-source/docs/options-for-laravel/access-control.md)

Opt-in per-option read and write rules, Gate abilities, acting as a user, bypassing for system jobs and CLI authorization.

#### [Config bridge](https://roundly-consulting.com/open-source/docs/options-for-laravel/config-bridge.md)

Let stored options override Laravel config() values at boot — change mail senders or the app name from the database.

#### [Caching](https://roundly-consulting.com/open-source/docs/options-for-laravel/caching.md)

The per-request memo and the persistent cache — what they hold, how writes keep them fresh, and how a flush works on any store.

#### [Import & export](https://roundly-consulting.com/open-source/docs/options-for-laravel/import-export.md)

Move options between environments or seed defaults with Options::export(), exportJson() and import() — or the matching Artisan commands.

#### [Artisan commands](https://roundly-consulting.com/open-source/docs/options-for-laravel/commands.md)

Eight commands to scaffold options and groups, list, get and set values, clear caches, and export or import settings.

#### [Testing](https://roundly-consulting.com/open-source/docs/options-for-laravel/testing.md)

Options::fake() records every write in memory with six assertions; or test against the real table with factory states.

#### [Exceptions](https://roundly-consulting.com/open-source/docs/options-for-laravel/exceptions.md)

Every package exception, when it’s thrown, and the framework exceptions you may also meet.

#### [Requirements](https://roundly-consulting.com/open-source/docs/options-for-laravel/requirements.md)

PHP 8.4+, Laravel 12 or 13, and Roundly’s package toolkit, which Composer installs for you.

## 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](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source.md)
