PHP code example of gumphp / think-crontab
1. Go to this page and download the library: Download gumphp/think-crontab 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/ */
gumphp / think-crontab example snippets
namespace app\crontab;
use gumphp\crontab\Crontab;
class Test extends Crontab
{
// 每秒执行一次
protected $rule = '* * * * * *';
public function handle()
{
$message = __METHOD__ . "\t" . date('Y-m-d H:i:s') . PHP_EOL;
error_log($message, 3, runtime_path() . 'debug.log');
}
}
return [
# ...
'handlers' => [
\app\crontab\Test::class,
],
];
bash
php think crontab start