Download the PHP package sw2eu/cron-command without Composer
On this page you can find all versions of the php package sw2eu/cron-command. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cron-command
CronCommand - automatized cron tasks
If you are familiar with Nette Framework and Symfony Console (especially implementation by Kdyby), you probably had idea to used it for cron operations. This tool will help you with maintenance of cron tasks.
Requirements
This library requires PHP 5.5 or higher. CronCommand library is designed for Nette Framework; however, it can be also used with other frameworks or pure PHP.
Installation
The best way to install this library is using Composer:
Documentation
Firstly, register extension Sw2\CronCommand\Bridges\Nette\DI\CronCommandExtension
. For more information about
configuration see the class definition. Some features would not work in version 0.8.x (simply - they are not yet been
implemented), so please be patient and stay tuned.
Now define your first task. Here is full source code of my AwesomeTask:
Annotation @cron
use the same syntax as you know from crontab. For the parsing of the cron expression is used
library mtdowling/cron-expression where you can find more information about syntax. Syntax with @
is not yet
supported (maybe in the future).
So now register your task to the cron runner:
This way you can create service and register it right to the runner. Tasks in CronCommandExtension
works in the same
way like services in Nette Framework. You can define just class name, or define the whole service with arguments,
setup, etc. The other way how to register your task is much more automatic: Just create service and tag it with
defined tag (default tag is sw2.cron.task
but can be also configured) like this:
You need not define kdyby.console.command
, it will be added automatically. So this mean, that every cron task is
automatically also console command -- can be started manually if needed.
Now you can run your first cron task using console command cron:runner
.
This library implements locking system. Every task can run only once at a time. If the task is running, you cannot start it manually and vice versa.
Advanced documentation will be added in the future. But if you look on my source codes, you will understand what you can do with this small (but powerful) library.
All versions of cron-command with dependencies
nette/reflection Version ~2.4
nette/safe-stream Version ~2.3
nette/utils Version ~2.4
kdyby/console Version ~2.6
mtdowling/cron-expression Version ~1.1