Yii2.0中实现规划任务
1.在 console/controllers 文件夹下创建一个把握器
<?php
namespace console\controllers;
use yii\console\Controller;
/**
* Test controller
*/
class TestController extends Controller {
public function actionIndex() {
echo "runnning success";
}
//参数测试
public function actionSend($name) {
echo "welcome to " . $name;
}
}
?>
注: (1)namespace console\controllers;必须有 (2)这个把握器该当应用号令行把握器的定名空间 use yii\console\Controller;
2.如何运行
我在 windows 下应用如式格式运行
D:\xampp\htdocs\yii2>d:\xampp\php\php yii test result :runnning success
3.如何传递参数
在 windows 中测试如下
D:\xampp\htdocs\yii2>d:\xampp\php\php yii test/send xiaoma
result:welcome to xiaoma