in advance template there is already a file yii. and there is no need to run it as php, it is linux script.
在高级模版中的 yii 文件,它是一个 Linux 脚本,不需要使用PHP来运行。
Create a controller in console/controllers
在 console/controllers 文件夹下创建一个控制器
I have created as TestController.php
我创建了一个名为 TestController.php 的文件
<?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;
}
}
This controller should be use the console controller name space
这个控制器应当使用命令行控制器的命名空间
use yii\console\Controller;
run it as
使用如下方式运行
新快购物系统是集合目前网络所有购物系统为参考而开发,不管从速度还是安全我们都努力做到最好,此版虽为免费版但是功能齐全,无任何错误,特点有:专业的、全面的电子商务解决方案,使您可以轻松实现网上销售;自助式开放性的数据平台,为您提供充满个性化的设计空间;功能全面、操作简单的远程管理系统,让您在家中也可实现正常销售管理;严谨实用的全新商品数据库,便于查询搜索您的商品。
0
yii test
I have test it on windows by running
我在 windows 下使用如下方式运行
D:\xampp\htdocs\yii2>d:\xampp\php\php yii test
cron service runnning
D:\xampp\htdocs\yii2>
yii test/mail [--to="hemctest@gmail.com"]
in windows for test it run as
在 windows 中测试如下
D:\xampp\htdocs\yii2>d:\xampp\php\php yii test/mail [--to="hemctest@gmail.com"]
Sending mail to [--to=hemctest@gmail.com]
官方命令行应用开发文档见此
英文原文: How to implement cron in Yii 2
本文由专注于成都网站建设的信易网络发布,更多关于yii的信息请关注信易网络随后的发布,信易网络的官网http://www.ir58.com
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号