nicoren / cron-bundle
Symfony cron
2.0.0
2026-10-14 18:53 UTC
Requires
- php: >=8.2
- doctrine/persistence: ^3.2 || ^4.0
- symfony/config: ^7.4 || ^8.0
- symfony/console: ^7.4 || ^8.0
- symfony/dependency-injection: ^7.4 || ^8.0
- symfony/filesystem: ^7.4 || ^8.0
- symfony/finder: ^7.4 || ^8.0
- symfony/framework-bundle: ^7.4 || ^8.0
- symfony/http-kernel: ^7.4 || ^8.0
- symfony/process: ^7.4 || ^8.0
- symfony/validator: ^7.4 || ^8.0
Requires (Dev)
- doctrine/doctrine-bundle: ^2.13 || ^3.0
- doctrine/mongodb-odm-bundle: ^5.0
- doctrine/orm: ^3.3
- phpunit/phpunit: ^12.0
- symfony/yaml: ^7.4 || ^8.0
Suggests
- ext-redis: To store running pids in Redis (storage.adapter: redis)
- doctrine/doctrine-bundle: To store jobs with Doctrine ORM (db_driver: orm)
- doctrine/mongodb-odm-bundle: To store jobs with Doctrine MongoDB ODM (db_driver: mongodb)
Provides
None
Conflicts
None
Replaces
None
README
Cron is schedule integration for symfony.
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: With symfony Flex :
composer config extra.symfony.allow-contrib true
composer require nicoren/cron-bundle
without symfony Flex :
composer require nicoren/cron-bundle
- Add the bundle to your application kernel : If you don't use Symfony flex
// app/AppKernel.php public function registerBundles() { $bundles = [ // ... new Nicoren\CronBundle\NicorenCronBundle(), ]; // ... }
- 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
- 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"
- 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--forceforces the job to be executed (even if disabled) based on the job schedule
Requirements
- PHP 8.2 or above
- Symfony 7.4 or 8
doctrine/mongodb-odm-bundle(db_driver: mongodb) ordoctrine/doctrine-bundle(db_driver: orm)ext-redisto store the running pids in redis
Use the 1.x versions for Symfony 4.4 / 5. See the changelog to upgrade.
Author and contributors
Nicolas RENAULT - nicoren44@gmail.com
License
CronBundle is licensed under the MIT license.