Introduction to the Zend Framework

Many PHP developers who start using the Zend Framework for the first time get always scared of the complexity of this framework. I'd like to say that there's nothing to be worried about. Yes, the Zend Framework is quite complex, but it's perhaps the best documented framework available on the web. This means that there's a reference guide, an online documentation and, above all, a myriad of high-level tutorials available online. In short: all of your present and future questions about this framework have already been answered.

Definition

The Zend Framework is defined as follows:

Zend Framework is an open source framework for developing web applications and services with PHP 5. Zend Framework is implemented using 100% object-oriented code. The component structure of Zend Framework is somewhat unique; each component is designed with few dependencies on other components. This loosely coupled architecture allows developers to use components individually. We often call this a "use-at-will" design.

This means that you can use this framework to develop web applications and sites with an higher level of flexibility and code reusability. For example, if you consider for a moment the architecture of a CMS such as Wordpress, you'll surely notice how presentation (markup) and core structure (PHP) are mixed together, thus preventing you from applying some radical changes to your framework architecture.

Instead, Zend completely keeps all the components of a project separated, so that you can easily change the underlying architecture of your site or application. This happens because Zend uses the MVC design pattern.

MVC: Model View Controller

Imagine your web site or application as made up of three separate components: the logic behind the actions performed on your site, the visual display of such actions (graphics, CSS, HTML, JavaScript) and the actions themselves. In other words, a Model, a View, and a Controller.

These components don't work alone: instead, they work together in a sort of continuous flow depicted in the following image:

As the documentation says:

  • Model - This is the part of your application that defines its basic functionality behind a set of abstractions. Data access routines and some business logic can be defined in the model.
  • View - Views define exactly what is presented to the user. Usually controllers pass data to each view to render in some format. Views will often collect data from the user, as well. This is where you're likely to find HTML markup in your MVC applications.
  • Controller - Controllers bind the whole pattern together. They manipulate models, decide which view to display based on the user's request and other factors, pass along the data that each view will need, or hand off control to another controller entirely. Most MVC experts recommend keeping controllers as skinny as possible.

Here are some good tutorials on the MVC pattern:

  1. The Model-View-Controller (MVC) Design Pattern for PHP

    A little bit obsolete (2006), but still valuable for understanding the basics behind MVC.

  2. Model View Controller(MVC) in PHP
  3. Build a PHP MVC Framework in One Hour (Part One)
  4. Build a PHP MVC Framework in One Hour (Part Two)

References

  1. Overview
    1. QuickStart
    2. APIs
    3. Reference Guide

Leave a Reply

Note: Only a member of this blog may post a comment.