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' ...
随机推荐
- perl 5.22手动安装Mysql DBI和DBD
mysql 手动安装DBI 和DBD: DBI版本: [root@dr-mysql01 DBD-mysql-4.033]# perl -MDBI -le 'print $DBI::VERSION;' ...
- 一步一步重写 CodeIgniter 框架 (10) —— 使用 CodeIgniter 类库(续)
上一节简单实现了 CI 的类库扩展模型,所以 _ci_load_class 和 _ci_init_class 写的不是很完备.根据上节课的分析,当 system/libraries 目录下存在 Ema ...
- Android实现 再按一次退出 的三种方法 durationTime、timerTask 和Handler
目前很多Android应用都会实现按返回键时提示“再按一次推退出” 在这篇文章中总结了各家的方法,一般都是监听Activity的onKeyDown 或者onBackPressed方法 方法一: 直接计 ...
- CSS - 解决使用浮动,父窗体不能撑高问题
浮动的父级元素一定要用 clear 清除浮动,否则高度会无法撑开.
- IOS Notification 通知中心
1. 通知中心概述 通知中心实际上是在程序内部提供了消息广播的一种机制.通知中心不能在进程间进行通信.实际上就是一个二传手,把接收到的消息,根据内部的一个消息转发表,来将消息转发给需要的对象. ...
- mysql 表级锁
表级锁:分为读锁和写锁: lock tables table_name read;//其他事务只能读,不能加写锁,要等待更新. SESSION 50 执行: mysql> update test ...
- [置顶] 让金融互联网-P2P网贷融资量增长10倍的广告宣传公益活动
我想做一件什么事?一个公益活动,所有资料都会共享出来--- 再次声明:这是一次公益,所有资料会公开. 我正在做一点事:收集各个P2P信贷公司(包括线上线下的),然后给线上P2P信贷公司做营销策略,教他 ...
- codeforces 437C The Child and Toy
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- PHP - 日期与时间
第10章 日期与时间 学习要点: 1.PHP日期和时间库 使用PHP编程时,与你遇到的大多数其他类型的数据相比,日期和时间有很大不同.因为日期和时间没有明确的结构,并且日期的计算和表示也很麻烦.在PH ...
- HttpURLConnection中使用代理(Proxy)及其验证(Authentication)
HttpURLConnection中使用代理(Proxy)及其验证(Authentication) 使用Java的HttpURLConnection类可以实现HttpClient的功能,而不需要依赖任 ...