1. Go to this page and download the library: Download yii2mod/yii2-cron-log 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/ */
public function actions()
{
return [
'cron' => 'yii2mod\cron\actions\CronLogAction',
// Also you can override some action properties in following way:
'cron' => [
'class' => 'yii2mod\cron\actions\CronLogAction',
'searchClass' => [
'class' => 'yii2mod\cron\models\search\CronScheduleSearch',
'pageSize' => 10
],
'view' => 'custom name of the view, which should be rendered.'
]
];
}
namespace app\commands;
use yii\console\Controller;
/**
* This command echoes the first argument that you have entered.
*
* This command is provided as an example for you to learn how to create console commands.
*
*/
class HelloController extends Controller
{
public function behaviors()
{
return [
'cronLogger' => [
'class' => 'yii2mod\cron\behaviors\CronLoggerBehavior',
'actions' => ['index']
],
// Example of usage the `MutexConsoleCommandBehavior`
'mutexBehavior' => [
'class' => 'yii2mod\cron\behaviors\MutexConsoleCommandBehavior',
'mutexActions' => ['index'],
'timeout' => 3600, //default 0
]
];
}
/**
* This command echoes what you have entered as the message.
* @param string $message the message to be echoed.
*/
public function actionIndex($message = 'hello world')
{
echo $message . "\n";
}
}