Skip to content

Attributes Overview

All behaviour in Simple Data Objects is declared via PHP attributes on constructor parameters (or on the class itself for #[TransformKeys]).

AttributeTargetPurpose
#[Cast]ParameterApply a type cast during hydration and serialization
#[Rules]ParameterLaravel validation rules
#[Flatten]ParameterInline nested DTO fields into the parent array
#[Hidden]ParameterExclude from toArray() / JSON output
#[IgnoreIfNull]ParameterOmit from output when value is null
#[MapPropertyName]ParameterMap a different input key to this property
#[TransformKeys]ClassTransform all input keys at the class level
#[DataCollection]ParameterDeclare a typed collection property

Released under the MIT License.