Models are a great way of providing functionality to our application, and they keep out the Controllers, nice and clean, from any critical logic. A hydrator is also great to transport properties and values from one model to another, that's why we will go into this a bit further to make optimal use of it.
For this recipe a working Zend Framework 2 skeleton application is necessary to make full use of the examples.
In this recipe we will set up a model and a method for hydrating data to and from our model, so that we have easy access of our data.
We can access the model anywhere in the application by simply adding a use statement at the top of our document:
use Application\Model\SampleModel; ...
No credit card required