Download the PHP package glpzzz/yii2-cron without Composer
On this page you can find all versions of the php package glpzzz/yii2-cron. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-cron
glpzzz/yii2-cron
Attribute-driven cron discovery and crontab synchronisation for Yii2 console applications.
Tag console actions with #[Cron], then let the module install/remove/list the matching
lines in the invoking user's crontab. A read-only web page shows what is declared and flags
any drift from what is actually installed.
Install
Wire it up
Mount the module (conventionally as cron) and point scan at the namespace/path that holds
your #[Cron] controllers. Put the shared parts in common/config/main.php:
and the console-only controller namespace in console/config/main.php:
The module registers manage (a yii\console\Controller) in console apps and status
(a yii\web\Controller) in web apps -- each only where it can run.
Tag actions
schedule: null marks an action as cron-manageable and documents it, but installs nothing.
Console commands
<route> is given without the module prefix, e.g. users/notify-for-insurance.
Run install-all --force --interactive=0 on deploy, after migrations.
Web status page
<module-mount>/status (e.g. /admin/cron/status) lists the discovered crons and, when the
web user can read its own crontab, flags missing / drifted / orphaned lines. It is
read-only -- the one place a web request runs crontab -l, and it never writes.
Access control is the host application's responsibility. The module knows nothing about your roles; protect the route with your app's access filter.
Testing
glpzzz\cron\testing\FakeCrontab and FakeCronScanner let you drive the controllers without
touching the real crontab. Bind them as the module's components in your test config:
Requirements
PHP >= 8.1, Yii 2.0.14+, a POSIX crontab binary on the host that runs the sync command.