Zend_Tool – Wolfgang’s crib sheet

Zend_Tool is a command line utility which comes with Zend Framework. It does not write your application code, but it creates the basic directory structure and skeleton files. Mastering its basic use will save you a lot of time.

I have put together a selection of the commands that I use regularly. For comprehensive lists and more in-depth information, please check out the links at the end of this page.

Installation

Download the latest Zend Framework from framework.zend.com.

Edit your .bashrc file and add a line for an alias which allows you to enter the Zend_Tool commands without specifying the directory of the respective zf.sh file.

alias zf='/home/yourusername/Downloads/Zend/bin/zf.sh'

Usage

Zend_Tool is a handy way to test whether a Zend Framework installation is working properly. Open a terminal and enter:
zf show version

Create the whole directory structure of a new project together with a skeleton of the configuration file application.ini:
zf create project MyProjectName

Create modules. I am far from understanding how they work… 🙁
zf create module Mysterymodule

Create controllers. Big timesaver: View files and directories are created automatically.
zf create controller Auth

There are lots of parameters that I have not yet got a clue about. In its default, the controller file will be populated with empty actions and the view scripts with sample/demo code.

For database use, the following example will create a model file that makes the table User available:
zf create dbtable User user

Forms like to sit in their own directory:
zf create form Auth

Create a layout.phtml file and modify application.ini accordingly:
zf enable layout

TO DOs

  • check out parameters to commands
  • learn about modules (and maybe write a page)
  • add more helpful links
  • write a page on application.ini and Zend_Config
  • write a page on database interaction with ZF

Helpful links

A concise overview in the ZF reference:
Using Zend_Tool On The Command Line

An online book about ZF by a programmer:
Zend Framework: Surviving The Deep End