Zend Framework 3 creators are big fans of various design patterns. Although you don't have to understand patterns to read this book, this section is intended to give you an idea of what design patterns ZF3 is based on.
Model-View-Controller (MVC) pattern. Model-View-Controller pattern is used in all modern PHP frameworks. In an MVC-application you separate your code into three categories: models (your business logic go here), views (your presentation goes here) and controllers (code responsible for interaction with user goes here). This is also called the separation of concerns. With MVC, you can reuse your components. It is also easy to substitute any part of this triad. For example, you can easily replace a view with another one, without changing your business logic.
Domain Driven Design (DDD) pattern. In Zend Framework 3, by convention, you will have model layer further divided into entities (classes mapped on database tables), repositories (classes used to retrieve entities from database), value objects (model classes not having identity), services (classes responsible for business logic).
Aspect Oriented Design pattern. In ZF3, everything is event-driven.
When a site user requests a page, an event is generated (triggered). A listener (or observer) can
catch event and do something with it. For example, Zend\Router
component
parses the URL and determines what controller class to call. When the event finally reaches the page
renderer, an HTTP response is generated and the user sees the web page.
Singleton pattern. In ZF3, there is the service manager object which is the centralized container of all services available in the application. Each service exists in a single instance only.
Strategy pattern. A strategy is just a class encapsulating some algorithm. And you can use different algorithms based on some condition. For example, the page renderer has several rendering strategies, making it possible to render web pages differently (the renderer can generate an HTML page, a JSON response, an RSS feed etc.)
Adapter pattern. Adapters allow to adapt a generic class to concrete use case.
For example, Zend\Db
component provides access to database in a generic way.
Internally, it uses adapters for each supported database (SQLite, MySQL, PostgreSQL and so on.)
Factory pattern. You can create an instance of a class using the new
operator. Or you can create it
with a factory. A factory is just a class encapsulating creation of other objects.
Factories are useful, because they simplify dependency injection. Using factories also
simplifies the testing of your model and controller classes.