Version 3.10.2 of spatie/laravel-settings is a small patch release that fixes one sharp edge: settings classes declaring properties typed as DateTimeInterface or CarbonInterface could be written to storage on 3.10.1, but threw an exception the moment they were read back. That is fixed now, and along the way the package picked up PHP 8.6 in its test matrix. Everything else stays the same — this is a non-breaking release with unchanged PHP and Laravel requirements.
What went wrong in 3.10.1
Settings classes hydrate their properties the moment they are resolved from the container, so a cast that fails during hydration takes the entire settings class down with it — not just the offending property.
The cast configuration in 3.10.1 assigned the default DateTimeInterfaceCast to any property typed with DateTimeInterface or an interface that extends it. Since Carbon\CarbonInterface extends DateTimeInterface, both of these declarations were wired up to the cast:
class AppSettings extends Settings
{
public DateTimeInterface $launched_at;
public ?CarbonInterface $deadline;
public static function group(): string
{
return 'app';
}
}
Saving worked fine, because the cast's write side serializes any DateTimeInterface implementation. Reading did not: the cast only knew how to hydrate a fixed list of concrete date classes, so it threw as soon as it met a property declared with an interface. In practice, a settings class like the one above became unusable the first time it was resolved.
The fix: hydrate through Laravel's date factory
Version 3.10.2 changes how the cast hydrates interface-typed values. Instead of matching against a hardcoded list of concrete classes, it now resolves them through Laravel's date factory — the same mechanism Eloquent's date casts use. That brings two immediate benefits:
- Properties typed
DateTimeInterfaceorCarbonInterfaceload correctly, including nullable ones. - The factory respects whatever date class your application registered with
Date::use(), so apps running immutable Carbon dates get immutable instances back.
Date::use(CarbonImmutable::class);
There are no schema or storage changes: values saved by earlier versions are read through the new hydration path, so no migration steps are needed.
Concretely typed date properties are unaffected
If your settings use concrete types — DateTime, DateTimeImmutable, Carbon, CarbonImmutable, or Laravel's own Carbon classes — their behavior is exactly the same as before. The fix only touches the hydration path for properties declared with an interface, so existing settings classes keep working without any changes.
If you added a workaround on 3.10.1 by switching a property from DateTimeInterface to a concrete type, you can now switch back if you prefer the looser typing.
More regression tests, and PHP 8.6 joins the matrix
The fix ships with regression coverage for the scenarios that matter: save-and-reload round trips, nullable date properties, timezone offsets, and applications that override the date factory with Date::use().
On the maintenance side, PHP 8.6 has been added to the GitHub Actions test matrix, which now runs the Pest suite on PHP 8.2 through 8.6 against Laravel 12 and 13, with existing 8.2–8.5 coverage untouched. The full matrix and PHPStan passed on the reviewed changes, and the local suites recorded 169 tests and 563 assertions on both Laravel 12 and Laravel 13, including all 13 Redis repository tests.
Upgrading
Update the package and you are done:
composer update spatie/laravel-settings
There are no configuration, migration, or code changes required. Thanks to @skybleak333 for the fix — the full diff between 3.10.1 and 3.10.2 is on GitHub.
In short:
- Settings classes with
DateTimeInterface- orCarbonInterface-typed properties no longer throw when read, as they did on 3.10.1. - Interface-typed dates hydrate through Laravel's date factory, so
Date::use()and immutable dates are respected. - Concrete date types behave exactly as before, and no workarounds are needed.
- It is a non-breaking patch: requirements are unchanged, and PHP 8.6 now runs the test matrix.