PHP code example of yii2mod / yii2-cron-log

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/ */

    

yii2mod / yii2-cron-log example snippets


php yii migrate/up --migrationPath=@yii2mod/cron/migrations

'components' => [
    'errorHandler' => [
        'class' => 'yii2mod\cron\components\ErrorHandler',
    ],
    'mutex' => [
        'class' => 'yii\mutex\FileMutex'
    ],
],

    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";
    }
}

return [
    'components' => [
        'i18n' => [
            'translations' => [
                'yii2mod-cron-log' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@yii2mod/cron/messages',
                ],
                // ...
            ],
        ],
        // ...
    ],
    // ...
];