Populating objects with data (commonly referred to hydration), and extraction of said data from objects, are two key aspects of building object-oriented applications. It doesn’t matter whether the data source is a Relational, NoSQL, or Graph database, a flat text file, or a form. We need to hydrate and extract data - a lot. But how do we do it effectively - especially when objects can be quite complex?
In this tutorial, I will teach you how to use the Zend Hydrator package to perform both hydration and extraction. We’ll start off working with simple objects, and hydrate them from a relational database. We’ll then, gradually, increase in complexity, showing how to hydrate increasingly complex objects. We’ll also see how to create flexible and sophisticated hydrators which can use a multitude of data sources, such as forms, along with how to extract data from hydrated o