多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全IT社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當前位置:首頁 > php框架 > ZendFramework > Zend Framework教程-用Zend命令行快速創(chuàng)建Zend應用

Zend Framework教程-用Zend命令行快速創(chuàng)建Zend應用

來源:程序員人生   發(fā)布時間:2013-12-27 22:21:36 閱讀次數(shù):4452次

  

      Zend Framework提供了命令行的方式快速創(chuàng)建應用,如果是用ZendStudio9,可能步采用命令行的方式,當時你稀飯的話,可以用。

      下載完整的庫文件包,在bin目錄的幾個腳本就是用來創(chuàng)建應用的。

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.11Usage:    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:  Version    zf show version mode[=mini] name-included[=1]    Note: There are specialties, use zf show version.? to get specific help on them.  Config    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.  Phpinfo    zf show phpinfo  Manifest    zf show manifest  Profile    zf show profile  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.  Application    zf change application.class-name-prefix class-name-prefix  Model    zf create model name module  View    zf create view controller-name action-name-or-simple-name module  Controller    zf create controller name index-action-included[=1] module  Action    zf create action name controller-name[=Index] view-included[=1] module  Module    zf create module name  Form    zf enable form module    zf create form name module  Layout    zf enable layout    zf disable layout  DbAdapter    zf configure db-adapter dsn section-name[=production]  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.  ProjectProvider    zf 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 創(chuàng)建一個項目
    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_demo2Creating project at /mydev_src/zend_framework_learn/www/zf_demo2Note: This command created a web project, for more information setting up your VHOST, please see docs/READMETesting 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總用量 28drwxr-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.phpdrwxr-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# 
創(chuàng)建成功,訪問一下:

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

顯示項目結構信息

 

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh show profileProjectDirectory    ProjectProfileFile    ApplicationDirectory        ConfigsDirectory            ApplicationConfigFile        ControllersDirectory            ControllerFile                ActionMethod            ControllerFile        ModelsDirectory        ViewsDirectory            ViewScriptsDirectory                ViewControllerScriptsDirectory                    ViewScriptFile                ViewControllerScriptsDirectory                    ViewScriptFile            ViewHelpersDirectory        BootstrapFile    DocsDirectory        file    LibraryDirectory    PublicDirectory        PublicIndexFile        HtaccessFile    TestsDirectory        TestPHPUnitConfigFile        TestPHPUnitBootstrapFile        TestApplicationDirectory            TestApplicationControllerDirectory                TestApplicationControllerFile        TestLibraryDirectoryroot@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# 

顯示Phpinfo
    zf.sh show phpinfo



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

zf.sh ?  (命令)



Config創(chuàng)建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

大體內(nèi)容

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

作用不言而喻。





Model 創(chuàng)建Model,可以指定模塊,也是創(chuàng)建全局的

    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 創(chuàng)建Controller,可以指定模塊,也是創(chuàng)建全局的
    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  testmodNote: 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.phpCreating an index action method in controller NewsManageCreating 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.phtmlUpdating 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創(chuàng)建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 創(chuàng)建視圖腳本
    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  testmodNote: 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.phpUpdating 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.phtmlUpdating 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  testmodUpdating 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  testmodUpdating 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 testmodCreating 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/filtersAdded a key for path module directory to the application.ini fileUpdating project profile '/mydev_src/zend_framework_learn/www/zf_demo2/.zfproject.xml'
配置文件中增加了

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"



Form創(chuàng)建Form
    zf enable form module

    zf create form name module

為指定模塊創(chuàng)建Form

root@coder-671T-M:/mydev_src/zend_framework_learn/www/zf_demo2# zf.sh create form testForm testmodCreating a form at /mydev_src/zend_framework_learn/www/zf_demo2/application/modules/testmod/forms/TestForm.phpUpdating 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 ... */    }}

創(chuàng)建全局的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 layoutA 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.phtmlUpdating 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 添加數(shù)據(jù)庫配置信息

    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 創(chuàng)建一個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提供的命令工具,可以根據(jù)需要使用,使用命令行要確保所有的東西都是用命令行完成的,因為命令行的運行是通過記錄在配置文件中完成的,如果手動加入一些功能,命令行就無法進行正確的運行了。



生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 日本.www| japanese日本护士com | 亚洲另类图片专区 | 欧美日韩中文国产一区 | 黑人性hd-| 日韩 欧美 亚洲国产 | 亚洲高清中文字幕一区二区三区 | 中文乱码精品一区二区三区 | 美国亚洲成年毛片 | 国产二区视频 | 性黑人 | 三级黄视频 | 亚洲免费视频在线 | 日本免费第一区二区三区 | 成人欧美一级毛片免费观看 | 成年人视频网站免费 | 欧美成人综合在线观看视频 | 国产成人一区二区三区视频免费 | 91丨九色丨首页在线观看 | 亚洲欧美精品天堂久久综合一区 | 亚洲在线免费免费观看视频 | 久久伊人免费视频 | 激情小说亚洲图片 | 亚洲国产一区二区三区最新 | 欧美日本一区 | 日韩欧美高清视频 | 精品剧情v国产在免费线观看 | 午夜久久久久久亚洲国产精品 | 亚洲精品国产第1页 | 亚洲不卡在线观看 | 国产精品久久现线拍久青草 | 精品中文字幕一区二区三区四区 | 亚洲精品国产福利片 | a色在线 | 亚洲成人在线视频网站 | 欧美自拍视频在线 | 亚洲视频一区二区在线观看 | 国产大片免费天天看 | 成人午夜视频在线播放 | 欧美极品video粗暴 | 久久久久999 |