教程以创建一个保存音乐专辑的Web 简单应用为例。下面是这个web应用的简单需求:
- 首页:显示专辑列表,并为每张专辑显示编辑/删除的链接,以及添加新专辑的链接。
- 添加新专辑:提供一个添加新专辑的表单。
- 编辑专辑:显示一个编辑专辑的表单。
- 删除专辑:确认删除并删除专辑功能。
相应地设计数据库结构如下(音乐专辑包括artist艺术家和title专辑名称):
Field name |
Type |
Null? |
Notes |
id |
integer |
No |
Primary key, auto increment |
artist |
varchar(100) |
No |
|
title |
varchar(100) |
No |
开始创建ZF应用
在命令行窗口跳转到Web服务器根目录,使用zend framework 命令行工具zf命令创建一个project 项目,比如名称为zftest:
cd /usr/local/apache2/htdocs
zf create project zftest
提示:
Note: This command created a web project, for more information setting up your VHOST, please see docs/README Testing Note: PHPUnit was not found in your include_path, therefore no testing actions will be created.
原来Zend Framework 开始官方支持PHPUnit了,Pear安装PHPUnit单元测试:http://pear.phpunit.de/
yum install php-pear
pear channel-discover pear.phpunit.de
pear upgrade
pear install phpunit/PHPUnit