---
title: "Events — Options for Laravel | Roundly"
description: "OptionSet, OptionForgotten and the opt-in OptionResolved — what each carries, when it fires and how to switch them off."
url: https://roundly-consulting.com/open-source/docs/options-for-laravel/events
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)

# Events

Writes and deletes dispatch events you can listen to for audit trails and integrations:

| Event | Properties | Fires on |
| --- | --- | --- |
| `OptionSet` | key, value, owner | set() — every write path, including setMany(), groups and remember() when it stores. |
| `OptionForgotten` | key, owner | forget() and reset(). |
| `OptionResolved` | key, value, owner | Every read, memo hits included — only with events.resolved enabled. |

```php
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\Options\Events\OptionForgotten;
use RoundlyConsulting\Options\Events\OptionSet;

Event::listen(OptionSet::class, function (OptionSet $event): void {
    logger()->info('Option changed', [
        'key' => $event->key,
        'owner' => $event->owner?->getKey(),
    ]);
});

Event::listen(OptionForgotten::class, function (OptionForgotten $event): void {
    // $event->key, $event->owner
});
```

## Switches

```bash
OPTIONS_EVENTS_ENABLED=true    # OptionSet + OptionForgotten (observers run either way)
OPTIONS_EVENTS_RESOLVED=true   # also OptionResolved on every read
```

- All three events need options.events.enabled (on by default). OptionResolved also needs options.events.resolved — it fires on every read, so it’s off by default.
- OptionSet and OptionResolved carry the cast value — the same value get() returns. For encrypted options that’s the plain value — keep it out of logs.
- OptionSet and OptionForgotten fire once the write is durable: at once outside a transaction, after the outermost commit inside one (DB::transaction(), setMany(), a group set()), and never for a write that rolls back.
- Events are dispatched synchronously; queue your listener if the work is slow.
- Turning events off silences only the events: the write calls observers and live config overrides itself, so they still run.

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