Artisan commands
php artisan make:option ThemeOption --cast=string --key=theme --encrypted --enum="App\Enums\Status"
php artisan make:option-group AppearanceSettings --options="App\Options\ThemeOption,App\Options\LocaleOption"
php artisan options:list [--owner=App\Models\User --owner-id=5]
php artisan options:get {option} [--owner= --owner-id= --as=<userKey>]
php artisan options:set {option} {value} [--owner= --owner-id= --json --as=<userKey>]
php artisan options:clear-cache
php artisan options:export [--owner= --owner-id= --path=storage/options.json]
php artisan options:import {path}| Command | What it does |
|---|---|
make:option | Scaffold an option class in app/Options. --key, --cast, --encrypted and --enum fill in the stub. |
make:option-group | Scaffold an OptionGroup in app/Settings; --options pre-fills the member list, each class fully qualified. |
options:list | Table of registered keys with readable name and resolved value, optionally for an owner. Warns when the registry is empty. |
options:get | Print the resolved value. Arrays and objects print as JSON, booleans as true / false. |
options:set | Persist a value; --json decodes it as JSON first. |
options:clear-cache | Flush the in-request memo and the persistent cache — works on every store. |
options:export | Export stored options as JSON to stdout, or to a file with --path. |
options:import | Upsert options from a JSON export file. |
{option} is a registered key or an option class-string. --owner takes a model class and needs --owner-id; the owner is loaded with findOrFail(). Package errors — an unknown option, an invalid owner class, a missing --owner-id or denied access — print a message and exit with a failure code.
Examples
php artisan options:set theme dark
php artisan options:set theme light --owner="App\Models\User" --owner-id=5
php artisan options:set notification-preferences '{"email":true,"sms":false}' --json
php artisan options:get theme --owner="App\Models\User" --owner-id=5
php artisan options:list --owner="App\Models\User" --owner-id=5options:list shows only registered keys, so register the options you want to inspect. make:option-group writes each --options class fully qualified (\App\Options\ThemeOption::class), so it resolves from the group’s own namespace. The commands bypass access control; options:get and options:set accept --as to run under a user’s rules (see Access control).
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 cryptoBy 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.