nicoren/cron-bundle

Symfony cron

Installs: 41

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 4

Type:symfony-bundle

1.0.8 2022-11-30 10:07 UTC

This package is auto-updated.

Last update: 2024-11-29 06:22:42 UTC


README

Cron is schedule integration for symfony.

Packagist Build Status Packagist License

Cron integration for symfony.

Installation

Installing this bundle can be done through these simple steps:

  1. Add the bundle to your project as a composer dependency: With symfony Flex :
composer config extra.symfony.allow-contrib true
composer require nicoren/cron-bundle

without symfony Flex :

composer require nicoren/cron-bundle
  1. Add the bundle to your application kernel : If you don't use Symfony flex
// app/AppKernel.php
public function registerBundles()
{
    $bundles = [
        // ...
        new Nicoren\CronBundle\CronCronBundle(),
    ];

    // ...
}
  1. Update your DB schema

3.1. ( doctrine ORM)

bin/console make:migration
bin/console doctrine:migrations:migrate

3.2. ( doctrine odm)

doctrine:mongodb:schema:update
  1. Configuration Overview: edit or create file config/packages/nicoren_cron.yaml
# config/packages/nicoren_cron.yaml
nicoren_cron:
    db_driver: mongodb # other valid values are 'mongodb' and 'couchdb'
    job_class: Nicoren\CronBundle\Model\Job
    timezone: "Europe/Paris"
  1. 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

Available commands

list

bin/console cron:job:list

Show a list of all jobs.

create

bin/console cron:job:create

Create a new job.

delete

bin/console cron:job:delete _jobId_

Delete a job. For your own protection, the job must be disabled first.

enable

bin/console cron:job:enable _jobId_

Enable a job.

disable

bin/console cron:job:disable _jobId_

Disable a job.

run all jobs schelduled at current time

bin/console cron:run

which we borrowed from Symfony. Make sure to check out php-cs-fixer as this will help you a lot.
Please note that --force forces the job to be executed (even if disabled) based on the job schedule

Requirements

PHP 7.3 or above

Author and contributors

Nicolas RENAULT - nicoren44@gmail.com

License

CronBundle is licensed under the MIT license.