最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

YII Framework框架教程之使用YIIC快速創(chuàng)建YII應用詳解

 更新時間:2016年03月15日 09:09:05   作者:coder  
這篇文章主要介紹了YII Framework框架教程之使用YIIC快速創(chuàng)建YII應用的方法,詳細分析說明了YII Framework框架使用YIIC命令行創(chuàng)建應用的相關技巧與注意事項,需要的朋友可以參考下

本文實例講述了YII Framework框架使用YIIC快速創(chuàng)建YII應用的方法。分享給大家供大家參考,具體如下:

yii提供了強大的命令行工具來快速的創(chuàng)建相關組件和應用。</span> 

cd進入yii/framework框架的根目錄。

執(zhí)行

# 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的基本命令參數(shù)規(guī)則

yiic <command-name> [parameters...]

command-name對應的有
 - message
 - migrate
 - shell
 - webapp

如果要查看具體的命令的功能可以用

yiic help <command-name>

例如:

php yiic shell

1.php yiic webapp

執(zhí)行 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. 
*/ 

在指定的位置創(chuàng)建一個基于yii的完整結構的webapp。app-path是webapp的存放目錄。如果目錄不存在會被創(chuàng)建。

例如:

/yii/framework# php yiic webapp ../../testwebap
 Create a Web application under '/home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap'? [Yes|No] Yes
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap
  generate index-test.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/themes
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/themes/classic
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/themes/classic/views
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/themes/classic/views/layouts
  generate themes/classic/views/.htaccess
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/themes/classic/views/site
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/themes/classic/views/system
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/css
  generate css/ie.css
  generate css/bg.gif
  generate css/screen.css
  generate css/form.css
  generate css/print.css
  generate css/main.css
  generate index.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/assets
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/models
  generate protected/models/LoginForm.php
  generate protected/models/ContactForm.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/components
  generate protected/components/UserIdentity.php
  generate protected/components/Controller.php
  generate protected/yiic.bat
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/controllers
  generate protected/controllers/SiteController.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/migrations
  generate protected/yiic
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/data
  generate protected/data/testdrive.db
  generate protected/data/schema.mysql.sql
  generate protected/data/schema.sqlite.sql
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/config
  generate protected/config/test.php
  generate protected/config/console.php
  generate protected/config/main.php
  generate protected/.htaccess
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/layouts
  generate protected/views/layouts/column1.php
  generate protected/views/layouts/column2.php
  generate protected/views/layouts/main.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/site
  generate protected/views/site/contact.php
  generate protected/views/site/login.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/views/site/pages
  generate protected/views/site/pages/about.php
  generate protected/views/site/index.php
  generate protected/views/site/error.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/messages
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/tests
  generate protected/tests/bootstrap.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/tests/fixtures
  generate protected/tests/phpunit.xml
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/tests/report
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/tests/unit
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/tests/functional
  generate protected/tests/functional/SiteTest.php
  generate protected/tests/WebTestCase.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/runtime
  generate protected/yiic.php
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/extensions
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/commands
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/protected/commands/shell
   mkdir /home/coder/adata/liuyuqiang/wamp/www/yii_dev/testwebap/images

Your application has been created successfully under /yii_dev/testwebap.

生成的目錄結構如下

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的國際化。

例如將上面生產(chǎn)的testwebap的
http://www.localyii.com/testwebap/index.php?r=site/login

登錄頁面的Username和Password   翻譯成中文

上面說需要配置文件。yii為我們提供了配置文件的模板。

framework/messages/config.php

復制framework\messages\config.php 文件到 protected\messages\下

具體內(nèi)容修改如下:

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')); ?>
textField($model,'username'); ?>
error($model,'username'); ?>
labelEx($model,Yii::t('login_message','password')); ?>
passwordField($model,'password'); ?>
error($model,'password'); ?>

執(zhí)行如下命令

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?r=site/login

可以看到翻譯成中文了。

可以有亂碼的問題,注意編碼問題。文件,瀏覽器要設置統(tǒng)一

更多關于Yii相關內(nèi)容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結》、《php優(yōu)秀開發(fā)框架總結》、《smarty模板入門基礎教程》、《php日期與時間用法總結》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家基于Yii框架的PHP程序設計有所幫助。

相關文章

  • php redis實現(xiàn)文章發(fā)布系統(tǒng)(用戶投票系統(tǒng))

    php redis實現(xiàn)文章發(fā)布系統(tǒng)(用戶投票系統(tǒng))

    這篇文章主要為大家詳細介紹了php redis實現(xiàn)文章發(fā)布系統(tǒng)以及用戶投票系統(tǒng),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • 強制PHP命令行腳本單進程運行的方法

    強制PHP命令行腳本單進程運行的方法

    本文介紹了一個強制PHP在單進程中執(zhí)行的函數(shù),多用在php命令行中和一些特殊需求的地方,需要的朋友可以參考下
    2014-04-04
  • Laravel框架實現(xiàn)發(fā)送短信驗證功能代碼

    Laravel框架實現(xiàn)發(fā)送短信驗證功能代碼

    這篇文章主要介紹了Laravel框架實現(xiàn)發(fā)送短信驗證的相關資料,非常錯具有參考借鑒價值,需要的朋友可以參考下
    2016-06-06
  • laravel5.4生成驗證碼的實例講解

    laravel5.4生成驗證碼的實例講解

    下面小編就為大家?guī)硪黄猯aravel5.4生成驗證碼的實例講解。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-08-08
  • php下載文件的代碼示例

    php下載文件的代碼示例

    php下載文件的代碼示例,需要的朋友可以參考下
    2012-06-06
  • php把時間戳轉換成多少時間之前函數(shù)的實例

    php把時間戳轉換成多少時間之前函數(shù)的實例

    下面小編就為大家?guī)硪黄猵hp把時間戳轉換成多少時間之前函數(shù)的實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-11-11
  • PHP可變變量學習小結

    PHP可變變量學習小結

    可變變量,就是一個變量的變量名可以動態(tài)的設置和使用。語法形式是PHP的特殊語法,其他語言中少見,本文給大家分享php可變變量學習小結,對php可變變量相關知識感興趣的朋友一起學習吧
    2015-11-11
  • Ajax PHP JavaScript MySQL實現(xiàn)簡易無刷新在線聊天室

    Ajax PHP JavaScript MySQL實現(xiàn)簡易無刷新在線聊天室

    這篇文章主要為大家詳細介紹了Ajax PHP JavaScript MySQL實現(xiàn)簡易無刷新在線聊天室,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-08-08
  • php實現(xiàn)網(wǎng)站插件機制的方法

    php實現(xiàn)網(wǎng)站插件機制的方法

    這些天想作一個在網(wǎng)站中實現(xiàn)插件的功能,谷歌了一下,發(fā)現(xiàn)一篇文章感覺對我?guī)椭艽螅鰜砗痛蠹曳窒?,廢話不多說,直接帖出代碼供大家分析.
    2009-11-11
  • laravel csrf驗證總結

    laravel csrf驗證總結

    這篇文章主要介紹了laravel csrf驗證總結,csrf是laravel表單提交和ajax請求為了安全設置的機制,有感興趣的同學可以深入學習下
    2021-03-03

最新評論

九江市| 舞钢市| 巴塘县| 临桂县| 密山市| 松原市| 图们市| 九台市| 襄汾县| 米泉市| 鹿泉市| 若羌县| 策勒县| 昆明市| 陆良县| 萍乡市| 寿阳县| 鄯善县| 济源市| 安国市| 南雄市| 凌海市| 宣威市| 林甸县| 西畴县| 华安县| 南木林县| 武定县| 南汇区| 康马县| 上高县| 文水县| 新丰县| 海晏县| 德州市| 南江县| 天祝| 石城县| 常德市| 察隅县| 山东|