Heim  >  Artikel  >  php教程  >  Yii2框架使用计划任务的方法,yii2框架计划任务

Yii2框架使用计划任务的方法,yii2框架计划任务

WBOY
WBOYOriginal
2016-06-13 08:38:021700Durchsuche

Yii2框架使用计划任务的方法,yii2框架计划任务

本文实例讲述了Yii2框架使用计划任务的方法。分享给大家供大家参考,具体如下:

<&#63;php
namespace console\controllers;
use yii\console\Controller;
/**
 * Test controller
 */
class TestController extends Controller {
  public function actionIndex() {
    echo "cron service runnning";
  }
  public function actionMail($to) {
    echo "Sending mail to " . $to;
  }
}

使用:

use yii\console\Controller;

执行

yii test
D:\xampp\htdocs\yii2>d:\xampp\php\php yii test cron service runnning D:\xampp\htdocs\yii2>

window下使用:

D:\xampp\htdocs\yii2>d:\xampp\php\php yii test/mail [--to="hemctest@gmail.com"]
Sending mail to [--to=hemctest@gmail.com]

更多关于Yii相关内容感兴趣的读者可查看本站专题:《Yii框架入门及常用技巧总结》、《php优秀开发框架总结》、《smarty模板入门基础教程》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn