Cron Bundle
Cron integration for symfony.
Installation
Installing this bundle can be done through these simple steps:
- Add the bundle to your project as a composer dependency:
composer require cron/cron-bundle- Add the bundle to your application kernel:
// app/AppKernel.php
public function registerBundles()
{
// ...
$bundle = array(
// ...
new Cron\CronBundle\CronCronBundle(),
);
// ...
return $bundles;
}- Update your DB schema
bin/console make:migration
bin/console doctrine:migrations:migrate- Start using the bundle:
bin/console cron:list
bin/console cron:run- To run your cron jobs automatically, add the following line to your (or whomever's) crontab:
* * * * * /path/to/symfony/install/app/console cron:run 1>> /dev/null 2>&1
OR If you don't have a dedicated cron daemon (e.g. in Heroku), you can use:
bin/console cron:start # will run in background mode, use --blocking to run in foreground
bin/console cron:stop # will stop the background cron daemonAvailable commands
list
bin/console cron:listShow a list of all jobs. Job names are show with [x] if they are enabled and [ ] otherwise.
create
bin/console cron:createCreate a new job.
delete
bin/console cron:delete _jobName_Delete a job. For your own protection, the job must be disabled first.
enable
bin/console cron:enable _jobName_Enable a job.
disable
bin/console cron:disable _jobName_Disable a job.
run
bin/console cron:run [--force] [job]which we borrowed from Symfony. Make sure to check out php-cs-fixer as this will help you a lot.
start
bin/console cron:start [--blocking]Start the cron as a daemon. By default it forks itself to the background and suppresses any output. The --blocking option will keep it in the foreground and will display output. This is useful when you don't have a dedicated cron daemon (e.g. on Heroku).
stop
bin/console cron:stopStops the background cron daemon started with cron:start. This is not applicable when the daemon was started with --blocking.
If you would like to help, take a look at the list of issues.
Requirements
PHP 5.5.9 or above
Author and contributors
Dries De Peuter - dries@nousefreak.be - http://nousefreak.be
See also the list of contributors who participated in this project.
License
CronBundle is licensed under the MIT license.