Yii Framework Framework Tutorial use YIIC quickly create a detailed application of Yii, Yiicyii
The example in this paper describes how the YII framework framework uses YIIC to quickly create a yii application. Share to everyone for your reference, as follows:
YII provides powerful command-line tools to quickly create related components and applications.
The CD enters the root directory of the Yii/framework framework.
Perform
# php Yiicyii Command Runner (based on Yii v1.1.8) USAGE:YIIC
[parameters ...] The following commands is available:-message-migrate-shell-webappto See individual command help, use the Followin G:
yiic
Help
Can see
Basic command parameter rules for YIIC
YIIC [Parameters ...]
Command-name corresponds to a
-Message
-Migrate
-Shell
-WebApp
If you want to see the functionality of a specific command, you can use
YIIC Help
For example:
PHP YIIC Shell
1.php Yiic WebApp
Execute PHP YIIC Help WebApp
/* USAGE YIIC webapp DESCRIPTION This command generates a YII WEB application at the specified location. PARAMETERS * app-path:required, the directory where the new application would be created. If The directory does not exist, it'll be created. After the application
Creates a webapp of the full structure of YII based on the specified location. App-path is the storage directory for WebApp. If the directory does not exist, it is created.
For example:
/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 gene Rate 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.
The resulting directory structure is as follows
Testwebap
│├──assets
│├──css
│├──images
│├──index.php
│├──index-test.php
│├──protected
│└──themes
The detailed directory structure is as follows
├──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
Look through the browser
http://www.localyii.com/testwebap/
The specific function is said later. The use of commands is directly spoken here.
2.php YIIC Messag
PHP YIIC help message Print the relevant usage of the message command
/* USAGE YIIC message
DESCRIPTION This command searches for messages to being translated in the specified source files and compiles them into P HP arrays as message source. PARAMETERS * config-file:required, the path of the configuration file. You can find a example in framework/messages/config.php. The file can be placed anywhere and must is a valid PHP script which returns an array of name-value pairs. Each name-value pair represents a configuration option. The following options is 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 is 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 is found in this list would be processed. If empty, all files would be processed. -Exclude:array, a list of directory anD file exclusions. Each exclusion can is either a name or a path. If a file or directory name or path matches the exclusion, it won't be copied. For example, an exclusion of '. SVN ' would exclude all files and directories whose name is '. SVN '. and an exclusion of '/a/b ' would exclude file or directory ' sourcepath/a/b '. -Translator:the name of the function for translating messages. Defaults to ' yii::t '. This was used as a mark to the find messages to be translated. -Overwrite:if message file must is overwritten with the merged messages. */
Mainly used for the internationalization of WebApp.
For example, the TESTWEBAP produced above
Http://www.localyii.com/testwebap/index.php?r=site/login
Login page username and password translated into Chinese
It says the configuration file is required. Yii provides us with a template for the configuration file.
framework/messages/config.php
Copy the framework\messages\config.php file to Protected\messages\
The specific content is modified as follows:
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
Modify the following
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 ');?>
Execute the following command
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.
The following files are generated in the directory
/www/yii_dev/testwebap/protected/messages/zh_cn/login_message.php
return Array (' password ' = ' = ', ' username ' + ', ');
Switch
return Array (' password ' = ' password ', ' username ' = ' user name ');
Modify
The following configuration file
/www/yii_dev/testwebap/protected/config/main.php
Add the following
Application-level parameters that can be accessed//using Yii::app ()->params[' paramname '] ' params ' =>array (// This was used in the contact page ' adminemail ' = ' webmaster@example.com ',, ' language ' = ' zh_cn ', ' sourcelanguage ' = ' en_US ',);
Visit for a moment
Http://www.localyii.com/testwebap/index.php?r=site/login
Can see translated into Chinese.
Can have garbled problem, pay attention to the coding problem. file, browser to set the unified
For more information on YII related content readers can view this site topic: "YII framework Introduction and common skills Summary", "PHP Excellent Development Framework Summary", "Smarty Template Primer Basic Tutorial", "PHP date and Time usage summary", "PHP object-oriented Programming introduction Tutorial", " PHP String Usage Summary, "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
It is hoped that this article is helpful to the PHP program design based on YII framework.
Articles you may be interested in:
- PHP YII Framework Development Little tricks Model (models) Rules custom validation rule
- Nginx configuration PHP Rewrite rules example of Yii and cakephp framework
- How to install the Yii framework using composer
- Yii method for executing SQL statements using the Migrate command
- Yii Framework framework uses YIIC to quickly create migrate usage examples of YII applications
- The internationalization realization method of YII Framework frame Tutorial
- A detailed description of the caching usage of YII Framework Framework Tutorial
- A detailed description of the security scheme for YII Framework Framework Tutorial
- A detailed description of the log usage of YII Framework Framework Tutorial
- An explanation of the exception handling of YII Framework Tutorial
- Example of common rules for YII rules
http://www.bkjia.com/PHPjc/1110078.html www.bkjia.com true http://www.bkjia.com/PHPjc/1110078.html techarticle The YII Framework Framework tutorial uses YIIC to quickly create a detailed application of Yii, Yiicyii This example describes how the YII framework framework uses YIIC to quickly create yii applications. Share to everyone ...