日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php框架 > ZendFramework > Zend Framework教程-用Zend命令行快速創建Zend應用

Zend Framework教程-用Zend命令行快速創建Zend應用

來源:程序員人生   發布時間:2013-12-27 22:21:36 閱讀次數:4459次

  

      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.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 創建一個項目
    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# 
創建成功,訪問一下:

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創建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  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創建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  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創建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 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 ... */    }}

創建全局的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 添加數據庫配置信息

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



生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 精品久久福利 | 欧美在线一区二区三区四区 | 国产精品成人一区二区三区 | 亚洲福利小视频 | 激情网站在线 | 在线观看中文字幕一区 | 狠狠草视频| 国产一区二区三区麻豆 | 欧美日韩综合一区 | 国产欧美久久一区二区三区 | 国产精品久久久99 | 国产日韩精品视频 | 一区二区视频在线 | 国产一级免费视频 | 国产精品一区二 | 日韩精品一区二区三区中文在线 | 人人精品| 99久免费精品视频在线观78 | 久久精品国产一区二区 | 极品视频在线 | 成人中文字幕在线观看 | 久久久精品一区二区三区 | 91久久精品一区 | 久久久久久网站 | 久久久久免费视频 | 免费精品国产的网站免费观看 | 国产又色又爽又黄又免费 | 色性视频| 99热免费在线 | 国产精品久久免费视频 | 99在线精品免费视频九九视 | 国产精品久久一区 | 国产一区福利 | 成人影院网站ww555久久精品 | 国产麻豆一区 | 天堂一区二区三区 | 日韩色综合 | 在线一区二区免费 | www.天天操.com | 日韩中文字幕av | 亚洲成人高清在线观看 |