当前位置:网站首页>yii中console方法调用,yii console定时任务
yii中console方法调用,yii console定时任务
2022-07-06 01:14:00 【gusijin】
yii除了用于构建 Web 应用程序的丰富功能,Yii 中也有一个拥有丰富功能的控制台, 它们主要用于创建网站后台处理的任务。
控制台应用程序的结构非常类似于 Yii 的一个 Web 应用程序。 它由一个或多个 yii\console\Controller 类组成,它们在控制台环境下通常被称为“命令”。 每个控制器还可以有一个或多个动作,就像 web 控制器。
你可以通过运行 yii 脚本,在位于仓库的基本目录中运行它。
1、定时任务编写
下载 Yii 框架后,可以看到有个 console 目录,里面有完整的目录结构:配置文件、控制器、模型等

2、新建 TestController.php 文件
<?php
namespace console\controllers;
use yii\console\Controller;
class TestController extends Controller
{
/** * @var 接收的参数 */
public $param;
//指定用于控制台的参数
public function options($actionID)
{
return [
'param',
];
}
/** * @name 脚本 */
public function actionDo()
{
echo $this->param.PHP_EOL;
}
}
3、运行 php yii test/do
用法
你可以使用以下语法来执行控制台控制器动作:
php yii [ --option1=value1 --option2=value2 … argument1 argument2 … ]

php yii test/do --param=123
显示:123
边栏推荐
- Gartner released the prediction of eight major network security trends from 2022 to 2023. Zero trust is the starting point and regulations cover a wider range
- Remember that a version of @nestjs/typeorm^8.1.4 cannot be obtained Env option problem
- Promise
- 基于DVWA的文件上传漏洞测试
- Curlpost PHP
- cf:D. Insert a Progression【关于数组中的插入 + 绝对值的性质 + 贪心一头一尾最值】
- Getting started with devkit
- Cve-2017-11882 reappearance
- Vulhub vulnerability recurrence 74_ Wordpress
- Starting from 1.5, build a micro Service Framework - call chain tracking traceid
猜你喜欢

SAP Spartacus home 页面读取 product 数据的请求的 population 逻辑

Illustrated network: the principle behind TCP three-time handshake, why can't two-time handshake?

Daily practice - February 13, 2022

False breakthroughs in the trend of London Silver

After Luke zettlemoyer, head of meta AI Seattle research | trillion parameters, will the large model continue to grow?

Exciting, 2022 open atom global open source summit registration is hot

毕设-基于SSM高校学生社团管理系统

普通人下场全球贸易,新一轮结构性机会浮出水面

Installation and use of esxi

Recoverable fuse characteristic test
随机推荐
cf:D. Insert a Progression【关于数组中的插入 + 绝对值的性质 + 贪心一头一尾最值】
Installation and use of esxi
Leetcode sword finger offer 59 - ii Maximum value of queue
MobileNet系列(5):使用pytorch搭建MobileNetV3并基于迁移学习训练
VSphere implements virtual machine migration
Vulhub vulnerability recurrence 74_ Wordpress
Xunrui CMS plug-in automatically collects fake original free plug-ins
Novice entry depth learning | 3-6: optimizer optimizers
DOM introduction
Use of crawler manual 02 requests
Threedposetracker project resolution
Four commonly used techniques for anti aliasing
JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
ThreeDPoseTracker项目解析
GNSS terminology
记一个 @nestjs/typeorm^8.1.4 版本不能获取.env选项问题
Nmap: network detection tool and security / port scanner
Hcip---ipv6 experiment
3D model format summary
ubantu 查看cudnn和cuda的版本