PHP code example of biwankaifa / thinkphp_cron
1. Go to this page and download the library: Download biwankaifa/thinkphp_cron library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
biwankaifa / thinkphp_cron example snippets
namespace app\tasks;
use jinyicheng\cron\Task;
class DemoTask extends Task
{
public function configure()
{
$this->daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释
}
/**
* 执行任务
* @return mixed
*/
protected function execute()
{
//...具体的任务执行
}
}
bash
php think cron:schedule