1. Configure the components required to perform the task
Task configuration file:/protected/config/console.php
Configuration method is almost the same as configuring the main file [HTML]
The configuration for YIIC console application.
Any writable Cconsoleapplication properties can is configured here.
Return Array (
' BasePath ' =>dirname (__file__). Directory_separator. '.. ',
' Name ' = ' My Console application ',
Application components
Auto-loaded model and component classes
' Import ' =>array (
' application.models.* ',//load all model classes under the ' application/models/' folder
' application.components.* ',//load all application component classes under the ' application/components/' folder
' application.extensions.* ',//load all application component classes under the ' application/extensions/' folder
),
' Components ' =>array (
Uncomment the following to use a MySQL database
' DB ' =>array (
' connectionString ' = ' mysql:host=localhost;dbname=dbname ',//Connect MySQL Database
' Emulateprepare ' = true,
' Username ' = ' root ',//mysql database user name
' Password ' = ' 123456 ',//mysql database user password
' CharSet ' = ' UTF8 ',//mysql database encoding
' Tableprefix ' = ' zd_ ',//mysql database table prefix
' Enableprofiling ' =>true,
' Enableparamlogging ' =>true,
),
Loading the email component
' Mailer ' = Array (
' Class ' = ' Application.extensions.mailer.EMailer ',
),
),
);
The configuration for YIIC console application.
Any writable Cconsoleapplication properties can is configured here.
Return Array (
' BasePath ' =>dirname (__file__). Directory_separator. '.. ',
' Name ' = ' My Console application ',
Application components
Auto-loaded model and component classes
' Import ' =>array (
' application.models.* ',//load all model classes under the ' application/models/' folder
' application.components.* ',//load all application component classes under the ' application/components/' folder
' application.extensions.* ',//load all application component classes under the ' application/extensions/' folder
),
' Components ' =>array (
Uncomment the following to use a MySQL database
' DB ' =>array (
' connectionString ' = ' mysql:host=localhost;dbname=dbname ',//Connect MySQL Database
' Emulateprepare ' = true,
' Username ' = ' root ',//mysql database user name
' Password ' = ' 123456 ',//mysql database user password
' CharSet ' = ' UTF8 ',//mysql database encoding
' Tableprefix ' = ' zd_ ',//mysql database table prefix
' Enableprofiling ' =>true,
' Enableparamlogging ' =>true,
),
Loading the email component
' Mailer ' = Array (
' Class ' = ' Application.extensions.mailer.EMailer ',
),
),
); 2. Task file
Under the/protected/commands/file directory, inherit the Cconsolecommand base class for the task file naming method for the task name +command
e.g. gocommand.php[html]
/**
* Automatically run files
*/
Class Gocommand extends Cconsolecommand
{
/**
* Dead Loop output
*/
Public Function run () {
for ($i =1; $i >0; $i + +) {
Self::echoword ($i);
Sleep (2);//sleep 2 seconds
Jump
if (i==500) {
Break
}
}
}
/**
* Output Hollo Word
*/
Public Function Echoword ($i) {
echo "Hollo word-$i \ n";
}
}
/**
* Automatically run files
*/
Class Gocommand extends Cconsolecommand
{
/**
* Dead Loop output
*/
Public Function run () {
for ($i =1; $i >0; $i + +) {
Self::echoword ($i);
Sleep (2);//sleep 2 seconds
Jump
if (i==500) {
Break
}
}
}
/**
* Output Hollo Word
*/
Public Function Echoword ($i) {
echo "Hollo word-$i \ n";
}
}3. Performing Tasks
Opens the command line tool, enters the project the/protected directory to enter the YIIC command to appear prompts, prompts the list to display the task file which just wrote [HTML]
E:\project\app\protected>yiic
Yii Command Runner (based on Yii v1.1.12)
usage:e:\zeee\zyd\protected\yiic.php [Parameters ...]
The following commands is available:
-Go
-MailQueue
-Message
-Migrate
-Shell
-WebApp
To see individual command help, use the following:
E:\project\app\protected>yiic
Yii Command Runner (based on Yii v1.1.12)
usage:e:\zeee\zyd\protected\yiic.php [Parameters ...]
The following commands is available:
-Go
-MailQueue
-Message
-Migrate
-Shell
-WebApp
To see individual command help, use the following: Execute command YIIC go for task handling
http://www.bkjia.com/PHPjc/477288.html www.bkjia.com true http://www.bkjia.com/PHPjc/477288.html techarticle 1. Configure the component task profile required to perform the task:/protected/config/console.php configuration method is similar to configuring the main file [HTML]? PHP//This is the configuration for Yi ...