Attributes
Carapace uses PHP attributes to provide powerful functionality with minimal boilerplate. This section covers the available attributes and how to use them.
NOTE
Each attribute page starts with badges indicating where it applies (Class, Property, or both) and in which pipeline stage it runs (Pre-hydration, Hydration, Serialization).
- CastWith - Cast values during hydration
- MapFrom - Map properties from custom input keys
- MapTo - Control output keys during serialization
- Hidden - Exclude properties from serialization (class or property)
- ConvertEmptyToNull - Convert empty strings/arrays to null during pre-hydration
- EnumSerialize - Control how enums are serialized (value, name, or a custom method)
- GroupFrom - Group multiple input keys into one array property
- SnakeCase - Serialize property names as snake_case