Yii --Command 任务处理
1.配置,执行任务所需要的组件
<?php // This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// application components // 自动载入的模型和组件类
'import'=>array(
'application.models.*',//载入"application/models/"文件夹下的所有模型类
'application.components.*',//载入"application/components/"文件夹下的所有应用组件类
'application.extensions.*',//载入"application/extensions/"文件夹下的所有应用组件类
), 'components'=>array(
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=dbname',//连接mysql数据库
'emulatePrepare' => true,
'username' => 'root',//MySQL数据库用户名
'password' => '123456',//MySQL数据库用户密码
'charset' => 'utf8',//MySQL数据库编码
'tablePrefix' => 'zd_', //MySQL数据库表前缀
'enableProfiling'=>true,
'enableParamLogging'=>true,
),
//加载Email组件
'mailer' => array(
'class' => 'application.extensions.mailer.EMailer',
),
),
);
2.任务文件
<?php /**
* 自动运行文件
*/
class GoCommand extends CConsoleCommand
{ /**
* 死循环输出
*/
public function run(){ for($i=1;$i>0;$i++){
self::echoWord($i);
sleep(2);//休眠2秒 //跳出
if(i==500){
break;
}
}
} /**
* 输出hollo word
*/
public function echoWord($i){
echo "hollo word --$i\n";
}
}
3.执行任务
E:\project\app\protected>yiic
Yii command runner (based on Yii v1.1.12)
Usage: E:\zeee\zyd\protected\yiic.php <command-name> [parameters...] The following commands are available:
- go
- mailqueue
- message
- migrate
- shell
- webapp To see individual command help, use the following:
执行命令 yiic go 可实现任务处理
Yii --Command 任务处理的更多相关文章
- yii2 ./yii command : No such file or directory
git clone下来的yii2后台项目,由于需要执行 ./yii migrate命令.执行之后,提示 No such file or directory 我从同样为yii2 basic的./yii ...
- Yii 初识
接管一个Yii的系统,因为没有文档,所以非常上火. 01 查版本 Yii::getVersion(); 02 生成webapp Yii 是支持通过命令行生成webapp的.其中, yiic.bat是W ...
- yii console
Here is a step by step to show how to run command in the server with yii framework. 1. Create the we ...
- yii int
@echo off rem ------------------------------------------------------------- rem Yii command line ini ...
- yii框架通过控制台命令创建定时任务
假设Yii项目路径为 /home/apps 1. 创建文件 /home/apps/web/protected/commands/console.php $yii = '/home/apps/frame ...
- YII Install 安装
Download Yii is an open source project released under the terms of the BSD License. This means t ...
- yii 核心类classes.php详解(持续更新中...)
classes.php在yii运行的时候将被自动加载,位于yii2文件夹底下. <?php /** * Yii core class map. * * This file is automati ...
- 拓展Yii Framework(易框架)
1.拓展yii 此文针对Yii1.1.15而写,请注意甄别你的Yii Framework 版本. 拓展yii是开发期间常见的代码处理方式.例如,你写一个新的controller(业务控制器),你通过继 ...
- Yii 框架学习--02 进阶
应用结构 入口文件 文件位置: web/index.php <?php //开启debug,应用会保留更多日志信息,如果抛出异常,会显示详细的错误调用堆栈 defined('YII_DEBUG' ...
随机推荐
- SSH整合,"sessionFactory " or "hibernateTemplate " is required异常
首先遇到的问题就是HibernateDaoSupport引起的,程序中所有的DAO都继承自HibernateDaoSupport,而HibernateDaoSupport需要注入sessionfact ...
- js词法作用域
作用域链和原型链是JS中比较重要的2个概念, JS的是函数作用域,与C之类语言的块级作用域不同 JS的作用域还是词法作用域,或者叫静态作用域,作用域链是在语法解析时就完成的,而不是在执行时创建. 例子 ...
- Bad Hair Day(单调栈 )
Bad Hair Day Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 15941 Accepted: 5382 Des ...
- VMware Workstation下VMnet1等虚拟网卡与主机网卡之间的关系
VMware Workstation下VMnet1等虚拟网卡与主机网卡之间的关系 本文出自 "王春海的博客" http://wangchunhai.blog.51cto.com/2 ...
- ant-学习记录二
<?xml version="1.0"?> <project name="targetStudy" default="mkdir&q ...
- JavaScript下全选反选的Demo程序里实现checkmeonly函数 DOM
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JS 2016-09-30T22:04:27.5220743+08:00 转换为日期
1.转换代码 new Date(item.CreatedDate).Format("yyyy-MM-dd hh:mm") 2.需要拓展的方法 // 对Date的扩展,将 Date ...
- xend调用xenstore的出错揭秘
近期发现几例问题,均是xend里面报了同一个错误 File "/usr/lib64/python2.4/site-packages/xen/xend/xenstore/xstransact. ...
- tab group of firefox
https://addons.mozilla.org/en-US/firefox/addon/tabgroups-menu/? src=search#detail-relnotes https://g ...
- CentOS: make menuconfig error: curses.h: No such file or directory
the problem when use centos5 to build kernel or busybox step 1. Centos中关于 ncurses.h:no such file or ...