Zend Framework提供了命令行的方式快速创建应用,如果是用ZendStudio9,可能步采用命令行的方式,当时你稀饭的话,可以用。

下载完整的库文件包,在bin目录的几个脚本就是用来创建应用的。

root@coder-671T-M:/mydev_src/zend_framework_learn/ZendFramework-1.11.11# tree -L 2
.
├── bin
│   ├── zf.bat
│   ├── zf.php
│   └── zf.sh
├── demos
│   └── Zend
├── documentation
│   ├── api
│   └── manual
├── externals
│   └── dojo
├── extras
│   ├── library
│   └── tests
├── incubator
├── INSTALL.txt
├── library
│   └── Zend
├── LICENSE.txt
├── README.txt
├── resources
│   └── languages
├── src
└── tests├── AllTests.php├── phpunit.xml├── resources├── runtests.sh├── TestConfiguration.php.dist├── TestHelper.php└── Zend20 directories, 11 files

具体给出的命令格式如下:

Zend Framework Command Line Console Tool v1.11.11
Usage:zf [--global-opts] action-name [--action-opts] provider-name [--provider-opts] [provider parameters ...]Note: You may use "?" in any place of the above usage string to ask for more specific help information.Example: "zf ? version" will list all available actions for the version provider.Providers and their actions:Versionzf show version mode[=mini] name-included[=1]Note: There are specialties, use zf show version.? to get specific help on them.Configzf create configzf show configzf enable configNote: There are specialties, use zf enable config.? to get specific help on them.zf disable configNote: There are specialties, use zf disable config.? to get specific help on them.Phpinfozf show phpinfoManifestzf show manifestProfilezf show profileProjectzf create project path name-of-profile file-of-profilezf show projectNote: There are specialties, use zf show project.? to get specific help on them.Applicationzf change application.class-name-prefix class-name-prefixModelzf create model name moduleViewzf create view controller-name action-name-or-simple-name moduleControllerzf create controller name index-action-included[=1] moduleActionzf create action name controller-name[=Index] view-included[=1] moduleModulezf create module nameFormzf enable form modulezf create form name moduleLayoutzf enable layoutzf disable layoutDbAdapterzf configure db-adapter dsn section-name[=production]DbTablezf create db-table name actual-table-name module force-overwriteNote: There are specialties, use zf create db-table.? to get specific help on them.ProjectProviderzf create project-provider name actions

为了运行方便可以把如下目录加入到path

/mydev_src/zend_framework_learn/ZendFramework-1.11.11/bin

设置临时的path,重启会失效的。

export PATH=$PATH:/mydev_src/zend_framework_learn/ZendFramework-1.11.11/bin

显示框架版本

root@coder-671T-M:~# zf.sh show version
Zend Framework Version: 1.11.11

Project 创建一个项目
    zf create project path name-of-profile file-of-profile
    zf show project
    Note: There are specialties, use zf show project.? to get specific help on them.

root@coder-671T-M:/mydev_src/zend_framework_learn/www# zf.sh create project zf_demo2
Creating project at /mydev_src/zend_framework_learn/www/zf_demo2
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.root@coder-671T-M:/mydev_src/zend_framework_learn/www# ll
总用量 28
drwxr-xr-x 6 root root 4096 2011-12-06 16:35 ./
drwxr-xr-x 9 root root 4096 2011-12-06 16:08 ../
drwxr-xr-x 4 root root 4096 2011-12-06 12:48 .metadata/
-rw-r--r-- 1 root root   17 2011-12-06 12:30 phpinfo.php
drwxr-xr-x 2 root root 4096 2011-12-06 12:48 RemoteSystemsTempFiles/
drwxr-xr-x 8 root root 4096 2011-12-06 13:56 zf_demo1/
drwxr-xr-x 7 root root 4096 2011-12-06 16:35 zf_demo2/
root@coder-671T-M:/mydev_src/zend_framework_learn/www#

创建成功,访问一下:

http://localzend.com/zf_demo2/public/

显示项目结构信息

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh show profile
ProjectDirectoryProjectProfileFileApplicationDirectoryConfigsDirectoryApplicationConfigFileControllersDirectoryControllerFileActionMethodControllerFileModelsDirectoryViewsDirectoryViewScriptsDirectoryViewControllerScriptsDirectoryViewScriptFileViewControllerScriptsDirectoryViewScriptFileViewHelpersDirectoryBootstrapFileDocsDirectoryfileLibraryDirectoryPublicDirectoryPublicIndexFileHtaccessFileTestsDirectoryTestPHPUnitConfigFileTestPHPUnitBootstrapFileTestApplicationDirectoryTestApplicationControllerDirectoryTestApplicationControllerFileTestLibraryDirectoryroot@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2#

显示Phpinfo
    zf.sh show phpinfo

查看指定命令的帮助信息:

zf.sh ?  (命令)

Config创建include_path配置文件
    zf create config
    zf show config
    zf enable config
    Note: There are specialties, use zf enable config.? to get specific help on them.
    zf disable config
    Note: There are specialties, use zf disable config.? to get specific help on them.
root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create config
Successfully written Zend Tool config.
It is located at: /root/.zf.ini

大体内容

php.include_path = "/mydev_src/zend_framework_learn/ZendFramework-1.11.11/library:.:/usr/share/php:/usr/share/pear"

作用不言而喻。

Model 创建Model,可以指定模块,也是创建全局的
    zf create model name module

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create model myModel testmod
Note: The canonical model name that is used with other providers is "MyModel"; not "myModel" as supplied
Creating a model at /mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/models/MyModel.php
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'

/zf_demo2/application/modules/testmod/models/MyModel.php

<?phpclass Testmod_Model_MyModel
{}

Controller 创建Controller,可以指定模块,也是创建全局的
    zf create controller name index-action-included[=1] module

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create controller NewsManage  1  testmod
Note: PHPUnit is required in order to generate controller test stubs.
Creating a controller at /mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/controllers/NewsManageController.php
Creating an index action method in controller NewsManage
Creating a view script for the index action method at /mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/views/scripts/news-manage/index.phtml
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'
root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2/application/modules# tree
.
└── testmod├── controllers│   └── NewsManageController.php├── forms│   └── TestForm.php├── models│   └── MyModel.php└── views├── filters├── helpers└── scripts└── news-manage└── index.phtml9 directories, 4 files

/zf_demo2/application/modules/testmod/controllers/NewsManageController.php

<?phpclass Testmod_NewsManageController extends Zend_Controller_Action
{public function init(){/* Initialize action controller here */}public function indexAction(){// action body}}

Action为指定controller创建action,默认是的controller是Index
    zf create action name controller-name[=Index] view-included[=1] module

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create action add NewsManage 1 testmod
Note: PHPUnit is required in order to generate controller test stubs.
Creating an action named add inside controller at /mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/controllers/NewsManageController.php
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'
Creating a view script for the add action method at /mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/views/scripts/news-manage/add.phtml
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2/application/modules# tree
.
└── testmod├── controllers│   └── NewsManageController.php├── forms│   └── TestForm.php├── models│   └── MyModel.php└── views├── filters├── helpers└── scripts└── news-manage├── add.phtml└── index.phtml9 directories, 5 files
<?phpclass Testmod_NewsManageController extends Zend_Controller_Action
{public function init(){/* Initialize action controller here */}public function indexAction(){// action body}public function addAction(){// action body}}

 View 创建视图脚本
    zf create view controller-name action-name-or-simple-name module

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create action edit  NewsManage  testmod
Note: PHPUnit is required in order to generate controller test stubs.
Creating an action named edit inside controller at /mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/controllers/NewsManageController.php
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'
Creating a view script for the edit action method at /mydev_src/zend_framework_learn/www/zf_demo2/application/views/scripts/news-manage/edit.phtml
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create view  NewsManage edit  testmod
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'
root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create view  NewsManage  editx  testmod
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'
.
└── testmod├── controllers│   └── NewsManageController.php├── forms│   └── TestForm.php├── models│   └── MyModel.php└── views├── filters├── helpers└── scripts└── news-manage├── add.phtml├── edit.phtml├── editx.phtml└── index.phtml9 directories, 7 files

Module
    zf create module name
为你的项目增加一个模块

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create module testmod
Creating the following module and artifacts:
/mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/controllers
/mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/models
/mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/views
/mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/views/scripts
/mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/views/helpers
/mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/views/filters
Added a key for path module directory to the application.ini file
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'

配置文件中增加了

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

Form创建Form
    zf enable form module

zf create form name module

为指定模块创建Form

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create form testForm testmod
Creating a form at /mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/forms/TestForm.php
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'

/zf_demo2/application/modules/testmod/forms/TestForm.php

<?phpclass Testmod_Form_TestForm extends Zend_Form
{public function init(){/* Form Elements & Other Definitions Here ... */}}

创建全局的Form

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create form testForm 
Creating a form at /mydev_src/zend_framework_learn/www/zf_demo2/application/forms/TestForm.php
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'
/zf_demo2/application/forms/TestForm.php

<?phpclass Application_Form_TestForm extends Zend_Form
{public function init(){/* Form Elements & Other Definitions Here ... */}}

Layout配置layout

zf enable layout
    zf disable layout

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh enable layout
A layout entry has been added to the application config file.
A default layout has been created at /mydev_src/zend_framework_learn/www/zf_demo2/application/layouts/scripts/layout.phtml
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"

/zf_demo2/application/layouts/scripts/layout.phtml

<?php echo $this->layout()->content; ?>

DbAdapter 添加数据库配置信息

zf configure db-adapter dsn section-name[=production]

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh configure db-adapter "adapter=Mysqli&username=uname&password=mypass&dbname=mydb"
A db configuration for the production section has been written to the application config file.

resources.db.adapter = "Mysqli"
resources.db.params.username = "uname"
resources.db.params.password = "mypass"
resources.db.params.dbname = "mydb"

DbTable 创建一个DbTable。
    zf create db-table name actual-table-name module force-overwrite
    Note: There are specialties, use zf create db-table.? to get specific help on them.

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create db-table  TblUser  tbl_user testmod 
Creating a DbTable at /mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/models/DbTable/TblUser.php
Updating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'

es# tree
.
└── testmod├── controllers│   └── NewsManageController.php├── forms│   └── TestForm.php├── models│   ├── DbTable│   │   └── TblUser.php│   └── MyModel.php└── views
<?phpclass Testmod_Model_DbTable_TblUser extends Zend_Db_Table_Abstract
{protected $_name = 'tbl_user';}

 

以上是zendframework提供的命令工具,可以根据需要使用,使用命令行要确保所有的东西都是用命令行完成的,因为命令行的运行是通过记录在配置文件中完成的,如果手动加入一些功能,命令行就无法进行正确的运行了。

Zend Framework教程-用Zend命令行快速创建Zend应用相关推荐

  1. 使用Maven命令行快速创建项目骨架(archetype)

    > mvn archetype:generate 接下来就会输出一些列带索引变化的archetype项可供我们选择,然后提示我们选择一个编号,可以直接回车选择默认的编号(392),然后就跟着一步 ...

  2. 如何在linux终端创建txt文件,在Linux中,如何使用 命令行 快速创建一个文本文件...

    如果需要创建文本文件,有一些易于使用的方法. 创建文本文件的第一个方法使用"cat"命令,在提示符下键入以下命令并按Enter,cat > sample.txt 按Enter ...

  3. php.ini开启命名空间,Zend Framework教程之模型Model基本规则和使用方法

    本文实例讲述了Zend Framework教程之模型Model基本规则和使用方法.分享给大家供大家参考,具体如下: 这里讲讲Zend中的model.其实Zend中的Model处理是相当简单的. 这主要 ...

  4. 专业级智能PHP IDE Zend Studio教程:Zend Framework 2集成(1/3)——创建和部署新的ZF2项目

    Zend Studio是新一代的专业级智能PHP IDE(应用程序开发环境).它旨在帮助开发人员提高工作效率,创造出高品质的PHP应用程序!它包含了PHP开发所必须的部件,通过一整套的编辑.调试.分析 ...

  5. mac终端里新建html文件,mac命令行终端怎么创建文件 mac命令行终端创建文件教程...

    mac命令行终端怎么创建文件?想要在mac os x系统中创建大容量空白文件其实非常简单.本文小乐哥为大家介绍两种创建文件教程,第一种就是使用mac命令行终端创建文件,第二种是使用磁盘工具应用. ma ...

  6. linux快速切换目录命令,Linux在命令行快速切换目录 - 米扑博客

    今天在微博上看到一个用命令行快速切换目录的文章,比之前自己的解决方案好了非常多,必须记录下来分享下. 每天在命令行下,一大部分的工作都是一遍又一遍的输入 cd ~/some/very/deep/oft ...

  7. linux 权限提示信息,命令行快速提示:权限进阶 | Linux 中国

    原标题:命令行快速提示:权限进阶 | Linux 中国 本部分介绍使用权限管理文件访问和共享的其他方法. -- Paul W. Frields 前一篇文章.本部分介绍使用权限管理文件访问和共享的其他方 ...

  8. 命令行快速删除当前行_在命令行中快速有效地工作

    命令行快速删除当前行 There are a lot of command line tips and trics in the internet. Most of them discribe the ...

  9. 给右键菜单加入CMD命令行快速通道(适合win7)

    给右键菜单加入CMD命令行快速通道(适合win7) 博客分类: Windows知识 PHPWindows  原文地址:http://www.unxmail.com/read.php?51   很多人都 ...

最新文章

  1. git server安装
  2. Android底层开发之Audio HAL Android Audio Overview
  3. 2.1 进行误差分析-深度学习第三课《结构化机器学习项目》-Stanford吴恩达教授
  4. WPF之无法触发KeyDown或者KeyUp键盘事件
  5. zookeeper 入门讲解实例 转
  6. 线性回归的Spark实现 [Linear Regression / Machine Learning / Spark]
  7. 桔子浏览器电脑版不显示图片怎么办 看不到图片怎么解决
  8. MFC开发IM-第二十七篇、如何引入acl,解决Json解析问题
  9. MySQL数据库基础(三)——SQL语言
  10. Navicat for MySQL 64位破解版
  11. Unity中文乱码的解决方法
  12. 区块链入门系列之P2P
  13. 一款APP的完整开发流程
  14. 算法的衡量:时间复杂度和空间复杂度
  15. 游戏技巧-《文明6》的C盘爆满问题
  16. 灰狼算法(GWO)优化xgboost的分类预测模型,多输入单输出模型,GWO-xgboost分类预测。
  17. 大数据和区块链区别和关系
  18. 潜规则------中国历史中的真实游戏 吴思
  19. 关于微信小程序VM22:2 (in promise) MiniProgramError {“errMsg“:“hideLoading:fail:toast can‘t be found“
  20. Eal:Error reading from file descriptor 33: Input/output error

热门文章

  1. 2015最新iherb海淘攻略-图文新手教程
  2. 【书籍-《定位》】定位的全面性
  3. 一种linux平台下算法库二进制文件加密方法探讨
  4. python中的int函数是什么意思
  5. 私有云新基建,浪潮云海超融合要做市场第一
  6. 电子货架标签----多种固定方式
  7. 【Python茴香豆系列】之 PANDAS 获取 DataFrame 的行数
  8. 如何使用GAMS的许可证
  9. html抽奖原理,抽奖器html
  10. 关于Adobe Photoshop 无法显示原始数据,内容太大。