enterdev / metodo
Metodo
Installs: 372
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- enterdev/cron-expression: ~1.2.0
- yiisoft/yii2: ~2.0.0
Requires (Dev)
This package is not auto-updated.
Last update: 2025-01-14 19:52:22 UTC
README
This extension provides scheduled task capability Yii framework 2.0.
The extension allows creating repeatable tasks or one-time tasks in the future.
Metodo is released under the MIT License. See the bundled LICENSE.md file.
Installation
- composer require enterdev/metodo
- composer install
- yii migrate --migrationPath=@vendor/enterdev/metodo/src/migrations
Usage
Metodo consists of two parts: crons and tasks. Cron is a rule to create tasks, they are used to schedule tasks. Tasks, however, are specific instructions, jobs to be performed. Tasks may or may not have a cron.
Metodo offers a daemon that runs tasks, but you can also run them manually if you know you're doing.
Configuration
Add metodo to your config modules
'modules' => [ 'metodo' => [ 'class' => 'enterdev\\metodo\\Module' ], ]
Running the daemon
run on supervisor or similar type of software:
yii metodo/scheduler/daemon
Creating a cron
The simplest cron that creates a task that will run every day:
$dailyJob1 = new MetodoCron(); $dailyJob1->tag = 'System'; $dailyJob1->hour = '0'; $dailyJob1->minute = '0'; $dailyJob1->second = '0'; $dailyJob1->exec_class = 'MockJob'; $dailyJob1->method = 'job1'; $dailyJob1->save();
see MetodoCronTest.php for more examples