上一节我们安装配置了Zend 框架,现在我们可以开始创建Zend Framework 项目了。本教程以创建一个保存音乐专辑的Web 简单应用为例。下面是这个web应用的简单需求:
相应地设计数据库结构如下(音乐专辑包括artist艺术家和title专辑名称):
开始创建ZF应用在命令行窗口跳转到Web服务器根目录,使用zend framework 命令行工具zf命令创建一个project 项目,比如名称为zftest: cd /var/www 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./ sudo apt-get install php-pear sudo pear channel-discover pear. sudo pear channel-discover pear.symfony-project.com sudo pear upgrade (Note:phpunit/PHPUnit requires PEAR Installer (version >= 1.9.4), installed version is 1.9.1) sudo pear install phpunit/PHPUnit 上面的Zend_Tool 命令行工具zf create project 创建项目时自动创建了各级目录和文件,仔细看下:
服务器配置文件比如Ubuntu 下配置apache: <VirtualHost *:80> DocumentRoot "/var/www/zftest/public" ServerName zftest.local # This should be omitted in the production environment SetEnv APPLICATION_ENV development <Directory "/var/www/zftest/public"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> sudo a2ensite zftest sudo /etc/init.d/apache2 reload 修改/etc/hosts 把zftest.local 指向127.0.0.1。访问http://zftest.local (或http://localhost/zftest/public/) 就能打开显示zf图标的页面了。zftest 这个Zend Framework 项目就算创建好了。 相关文章 |
|