Fabulous PHP frameworks: Zend Framework

The Zend Framework offers a comprehensive feature set and popular components in return for a significant time investment

1 2 3 Page 2
Page 2 of 3

Zend Framework libraries and tools
Download and unpack Zend Framework, and you get a collection of libraries organized within a directory structure. Zend provides a command-line tool, zf, that jump-starts the creation of specific pieces of an application by generating scaffolding code, placing that code in the proper files, building the proper subdirectory structures, and storing each file in its correct subdirectory. To create an application, you define the application's Web root directory, then use the zf tool to build the directory structure using a command like the following:

zf create project <project-name>

This creates a <project-name> directory in the Web root and adorns that directory with all necessary subdirectories.

The zf tool also builds controllers, models, views, actions within controllers, and even data-entry forms. Suppose you've defined a database with a table that tracks music albums, and you want to create a skeletal class for accessing that table. You would enter the following:

zf create db-table Albums albums

Similarly, if you've already defined an Index controller for your application and want to add a delete action to it, the zf tool will get you started with the following:

zf create action delete Index

In all these examples, the zf tool is building skeletal files, classes, and methods. It's up to you to hang the flesh on the bones.

A controller's operations are called actions, each of which is executed by a public function referred to as an action function. Action functions can also be implemented in model classes. For example, the action function that updates an Album within an Albums database must be named updateAlbum().

While the number of directories and subdirectories required by a Zend Framework application might be daunting, this complexity is actually organization. (This is true for most of the other frameworks in this review.) Every subdirectory houses specific application components. Controller source files go in the controllers subdirectory, model source files in the models subdirectory, JavaScript files used by views in the views/scripts subdirectory, and so on. It is truly a case of "a place for everything, and everything in its place."

In addition, class and method names follow well-defined convention, and this imposition of name structure permeates the Zend Framework. The benefits are twofold: It not only makes the function of a class or method instantly apparent, it also allows the PHP runtime to use introspection to locate which class or method is responsible for a particular piece of functionality at runtime. This latter feature of naming conventions allows the system's front end to map a particular URL to a given action. The controller peels the URL apart and uses its components to locate which class and which action within the class should handle the HTTP request.

Zend Framework design patterns
The core of Zend's model subsystem is Zend_Db. Rather than implementing a single design pattern, Zend_Db is a collection of different patterns. At its heart is the adapter pattern, but it also uses the façade pattern to provide an object-oriented interface for building dynamic queries. The Zend_Db_Table subclass of Zend_Db implements the table data gateway pattern, and the Zend_Db_Table_Row class implements the row data gateway pattern.

1 2 3 Page 2
Page 2 of 3
How to choose a low-code development platform