shlogg · Early preview
Paul Redmond @paulredmond

Type-Safe PHP Object Hydration With DataModel

Hydrate type-safe PHP objects recursively with `Zerotoprod\DataModel`. Simplify object hydration, ensure type safety & reduce defensive programming. Control value resolution with #[Describe()] attribute. Non-invasive integration via trait usage.

This PHP Data Model package provides a lightweight, non-invasive way to hydrate type-safe PHP objects recursively. It uses reflection and PHP attributes to hydrate objects and instantiate them based on type hints:
class Address{    use \Zerotoprod\DataModel\DataModel;     public string $street;    public string $city;} class User{    use \Zerotoprod\DataModel\DataModel;     public string $username;    public Address $address;} $User = User::from([    'username' => 'John Doe',    'address' => [        'street' => '123 Main St',        'city' => 'Hometown',    ],]); echo $User->address->city; //...