O'Reilly logo

Zend Framework 2 Cookbook by Josephus Callaars

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Model and a Hydrator

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.

Getting ready

For this recipe a working Zend Framework 2 skeleton application is necessary to make full use of the examples.

How to do it…

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.

Accessing the Model

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required