---
title: "Helpers, registry & Blade — Options for Laravel | Roundly"
description: "The options() and setting() helpers, short string keys through the registry, and the escaped @option Blade directive."
url: https://roundly-consulting.com/open-source/docs/options-for-laravel/helpers-registry
language: en
---

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

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

# Helpers, registry & Blade

Two global helpers cover the common cases. Both are function\_exists-guarded, so your app can define its own instead:

```php
options();                              // OptionsManager instance
options(ThemeOption::class);            // global value
options(ThemeOption::class, $user);     // scoped value
options()->set(ThemeOption::class, 'dark');

setting('theme');                       // identical alias
setting('theme', $user);
```

## String-key registry

Register short keys so options resolve by string — useful in Blade, config-driven UIs and the CLI. Register them in a service provider:

```php
use RoundlyConsulting\Options\Facades\Options;

// In a service provider’s boot()
Options::register([
    'theme'  => ThemeOption::class,
    'locale' => LocaleOption::class,
]);

Options::key('theme')->get();
options('theme', $user);
Options::for($user)->key('theme')->set('dark');

Options::registered();            // ['theme' => ThemeOption::class, …]
Options::resolveClass('theme');   // ThemeOption::class
```

Or declare them in config:

```php
// config/options.php
'registry' => [
    'theme'  => App\Options\ThemeOption::class,
    'locale' => App\Options\LocaleOption::class,
],
```

- Runtime registrations win over config entries with the same key.
- A registry key is only a lookup alias — the value is still stored under the option’s key().
- Dotted keys such as profile.theme are a naming convention; they aren’t stored as groups.
- Registry keys and class-strings funnel through one resolver; an unknown key or class throws InvalidOptionClassName.

## Blade directive

```blade
{{-- registered key or class-string; output is HTML-escaped --}}
@option('theme')
@option(\App\Options\ThemeOption::class)

{{-- the arguments are passed straight to options(), so an owner works too --}}
@option('theme', auth()->user())
```

@option compiles to options(...) wrapped in e(), so output is HTML-escaped and access control applies. If your app already defines an @option directive, the package leaves yours in place and skips its own.

## 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/docs/options-for-laravel.md)
