本文实例讲述了YII Framework框架使用YIIC快速创建YII应用的方法。分享给大家供大家参考,具体如下:
yii提供了强大的命令行工具来快速的创建相关组件和应用。</span>
cd进入yii/framework框架的根目录。
执行
# php yiic Yii command runner (based on Yii v1.1.8) Usage: yiic <command-name> [parameters...] The following commands are available: - message - migrate - shell - webapp To see individual command help, use the following: yiic help <command-name>
可以看到
yiic的基本命令参数规则
yiic <command-name> [parameters...]
command-name对应的有
- message
- migrate
- shell
- webapp
如果要查看具体的命令的功能可以用
yiic help <command-name>
例如:
php yiic shell
1.php yiic webapp
执行 php yiic help webapp
/* USAGE yiic webapp <app-path> DESCRIPTION This command generates an Yii Web Application at the specified location. PARAMETERS * app-path: required, the directory where the new application will be created. If the directory does not exist, it will be created. After the application is created, please make sure the directory can be accessed by Web users. */
在指定的位置创建一个基于yii的完整结构的webapp。app-path是webapp的存放目录。如果目录不存在会被创建。
例如:
/yii/framework# php yiic webapp ../../testwebap Create a Web application under '/home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap'"color: #0000ff">testwebap
│ ├── assets
│ ├── css
│ ├── images
│ ├── index.php
│ ├── index-test.php
│ ├── protected
│ └── themes
详细目录结构如下
├── assets
├── css
│ ├── bg.gif
│ ├── form.css
│ ├── ie.css
│ ├── main.css
│ ├── print.css
│ └── screen.css
├── images
├── index.php
├── index-test.php
├── protected
│ ├── commands
│ │ └── shell
│ ├── components
│ │ ├── Controller.php
│ │ └── UserIdentity.php
│ ├── config
│ │ ├── console.php
│ │ ├── main.php
│ │ └── test.php
│ ├── controllers
│ │ └── SiteController.php
│ ├── data
│ │ ├── schema.mysql.sql
│ │ ├── schema.sqlite.sql
│ │ └── testdrive.db
│ ├── extensions
│ ├── messages
│ ├── migrations
│ ├── models
│ │ ├── ContactForm.php
│ │ └── LoginForm.php
│ ├── runtime
│ ├── tests
│ │ ├── bootstrap.php
│ │ ├── fixtures
│ │ ├── functional
│ │ │ └── SiteTest.php
│ │ ├── phpunit.xml
│ │ ├── report
│ │ ├── unit
│ │ └── WebTestCase.php
│ ├── views
│ │ ├── layouts
│ │ │ ├── column1.php
│ │ │ ├── column2.php
│ │ │ └── main.php
│ │ └── site
│ │ ├── contact.php
│ │ ├── error.php
│ │ ├── index.php
│ │ ├── login.php
│ │ └── pages
│ │ └── about.php
│ ├── yiic
│ ├── yiic.bat
│ └── yiic.php
└── themes
└── classic
└── views
├── layouts
├── site
└── system通过浏览器查看一下
http://www.localyii.com/testwebap/
具体功能后面讲。这里直接讲命令的使用。
2.php yiic messag
php yiic help message打印message命令的相关用法
/* USAGE yiic message <config-file> DESCRIPTION This command searches for messages to be translated in the specified source files and compiles them into PHP arrays as message source. PARAMETERS * config-file: required, the path of the configuration file. You can find an example in framework/messages/config.php. The file can be placed anywhere and must be a valid PHP script which returns an array of name-value pairs. Each name-value pair represents a configuration option. The following options are available: - sourcePath: string, root directory of all source files. - messagePath: string, root directory containing message translations. - languages: array, list of language codes that the extracted messages should be translated to. For example, array('zh_cn','en_au'). - fileTypes: array, a list of file extensions (e.g. 'php', 'xml'). Only the files whose extension name can be found in this list will be processed. If empty, all files will be processed. - exclude: array, a list of directory and file exclusions. Each exclusion can be either a name or a path. If a file or directory name or path matches the exclusion, it will not be copied. For example, an exclusion of '.svn' will exclude all files and directories whose name is '.svn'. And an exclusion of '/a/b' will exclude file or directory 'sourcePath/a/b'. - translator: the name of the function for translating messages. Defaults to 'Yii::t'. This is used as a mark to find messages to be translated. - overwrite: if message file must be overwritten with the merged messages. */主要用于webapp的国际化。
例如将上面生产的testwebap的
http://www.localyii.com/testwebap/index.php"htmlcode">dirname(__FILE__).DIRECTORY_SEPARATOR.'..', 'messagePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'messages', 'languages'=>array('zh_cn'), 'fileTypes'=>array('php'), 'overwrite'=>true, 'exclude'=>array( '.svn', 'yiilite.php', 'yiit.php', '/i18n/data', '/messages', '/vendors', '/web/js', ), );/www/yii_dev/testwebap/protected/views/site/login.php
修改如下
labelEx($model,Yii::t('login_message','username')); "htmlcode">testwebap/protected/messages /www/yii_dev/yii/framework# php yiic message "../../testwebap/protected/messages/config.php" Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/components/Controller.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/components/UserIdentity.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/config/console.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/config/main.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/config/test.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/controllers/SiteController.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/models/ContactForm.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/models/LoginForm.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/tests/WebTestCase.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/tests/bootstrap.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/tests/functional/SiteTest.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/layouts/column1.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/layouts/column2.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/layouts/main.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/site/contact.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/site/error.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/site/index.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/site/login.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/site/pages/about.php... Extracting messages from /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/yiic.php... Saving messages to /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/messages/../messages/zh_cn/login_message.php...saved.目录下生成如下文件
/www/yii_dev/testwebap/protected/messages/zh_cn/login_message.php
return array ( 'password' => '', 'username' => '', );改为
return array ( 'password' => '密码', 'username' => '用户名', );修改
如下配置文件
/www/yii_dev/testwebap/protected/config/main.php
添加如下
// application-level parameters that can be accessed // using Yii::app()->params['paramName'] 'params'=>array( // this is used in contact page 'adminEmail'=>'webmaster@example.com', ), 'language'=>'zh_cn', 'sourceLanguage'=>'en_us', );访问一一下
http://www.localyii.com/testwebap/index.php"_blank" href="https://www.jb51.net/Special/386.htm">Yii框架入门及常用技巧总结》、《php优秀开发框架总结》、《smarty模板入门基础教程》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]