Home >Backend Development >PHP Tutorial >Yii2 framework uses the method of scheduled tasks, yii2 framework scheduled tasks_PHP tutorial
This article describes the example of Yii2 framework using scheduled tasks. Share it with everyone for your reference, the details are as follows:
<?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:
use yii\console\Controller;
Execute
yii test D:\xampp\htdocs\yii2>d:\xampp\php\php yii test cron service runnning D:\xampp\htdocs\yii2>
Use under window:
D:\xampp\htdocs\yii2>d:\xampp\php\php yii test/mail [--to="hemctest@gmail.com"] Sending mail to [--to=hemctest@gmail.com]
Readers who are interested in more Yii-related content can check out the special topics on this site: "Introduction to Yii Framework and Summary of Common Techniques", "Summary of Excellent PHP Development Framework", "Basic Tutorial for Getting Started with Smarty Templates", "php Date and Time" Usage Summary", "php object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "php common database operation skills summary"
I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.