PHPackages                             tourze/doctrine-cron-job-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/doctrine-cron-job-bundle

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tourze/doctrine-cron-job-bundle
===============================

Doctrine CronJob Bundle

1.0.0(6mo ago)04MITPHPCI failing

Since Apr 15Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/doctrine-cron-job-bundle)[ Packagist](https://packagist.org/packages/tourze/doctrine-cron-job-bundle)[ RSS](/packages/tourze-doctrine-cron-job-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (25)Versions (7)Used By (0)

Doctrine CronJob Bundle
=======================

[](#doctrine-cronjob-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/89736971a87803661fe8841a8088ede376f1dd636e257abf4b4c4c9e7c82692d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f646f637472696e652d63726f6e2d6a6f622d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-cron-job-bundle)[![Total Downloads](https://camo.githubusercontent.com/5fa296a45e9ebeb9b5bfb837a4dab0d736f4c66e00c21ee814cc313db463b8f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f646f637472696e652d63726f6e2d6a6f622d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-cron-job-bundle)[![PHP Version](https://camo.githubusercontent.com/9af30d5dd7f717254e409028e74f165a4ae69674cd70dda0e5c63ed1237eb96d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f646f637472696e652d63726f6e2d6a6f622d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-cron-job-bundle)[![License](https://camo.githubusercontent.com/24514846ad957814a7b75b4ce2e9232062f13338fc19a5552196df877e2cfdcd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f646f637472696e652d63726f6e2d6a6f622d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-cron-job-bundle)[![Coverage](https://camo.githubusercontent.com/994d68acb2aadf1c3c7711ddcb3b30429246a6c05da9e601f62c3f932ac795a8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](#testing)

A Symfony bundle that provides database-managed cron jobs with Doctrine ORM integration. This bundle allows you to store and manage cron jobs and scheduled SQL queries in your database.

Features
--------

[](#features)

- 🗄️ **Database-managed cron jobs** - Store cron job configurations in database
- 📅 **Scheduled SQL execution** - Execute SQL queries at specified intervals
- 🔄 **Symfony integration** - Seamless integration with Symfony's cron job system
- 🏗️ **Entity management** - Full Doctrine ORM entities with repository services
- 📊 **Tracking &amp; auditing** - Built-in tracking and user attribution
- ⚡ **Performance optimized** - Efficient query execution with caching support

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Symfony 6.4 or higher
- Doctrine ORM 3.0 or higher

Installation
------------

[](#installation)

```
composer require tourze/doctrine-cron-job-bundle
```

Quick Start
-----------

[](#quick-start)

1. **Register the Bundle**

```
// config/bundles.php
return [
    // ...
    Tourze\DoctrineCronJobBundle\DoctrineCronJobBundle::class => ['all' => true],
];
```

2. **Create and manage cron jobs**

```
use Tourze\DoctrineCronJobBundle\Entity\CronJob;

// Create a new cron job
$job = new CronJob();
$job->setName('daily-cleanup');
$job->setCommand('php bin/console app:cleanup');
$job->setSchedule('0 2 * * *'); // Run at 2 AM daily
$job->setDescription('Daily cleanup task');
$job->setValid(true);

$entityManager->persist($job);
$entityManager->flush();
```

3. **Create scheduled SQL queries**

```
use Tourze\DoctrineCronJobBundle\Entity\CronSql;

// Create a scheduled SQL query
$cronSql = new CronSql();
$cronSql->setTitle('User Statistics');
$cronSql->setSqlStatement('SELECT COUNT(*) as total_users FROM users WHERE created_at >= DATE_SUB(NOW(), INTERVAL 1 DAY)');
$cronSql->setCronExpression('0 0 * * *'); // Run at midnight
$cronSql->setValid(true);

$entityManager->persist($cronSql);
$entityManager->flush();
```

Configuration
-------------

[](#configuration)

The bundle works out of the box with default settings. For advanced configuration:

```
# config/packages/doctrine_cron_job.yaml
doctrine_cron_job:
    # Configure any specific settings here
    # Default configuration is sufficient for most use cases
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Providers

[](#custom-providers)

You can extend the functionality by creating custom providers:

```
use Tourze\DoctrineCronJobBundle\Provider\DoctrineProvider;

class CustomCronProvider extends DoctrineProvider
{
    // Implement custom logic
}
```

### Repository Usage

[](#repository-usage)

```
use Tourze\DoctrineCronJobBundle\Repository\CronJobRepository;
use Tourze\DoctrineCronJobBundle\Repository\CronSqlRepository;

// Get active cron jobs
$activeJobs = $cronJobRepository->findBy(['valid' => true]);

// Get SQL jobs by expression
$dailyJobs = $cronSqlRepository->findBy(['cronExpression' => '0 0 * * *']);
```

Security
--------

[](#security)

- **SQL Injection Prevention**: All SQL statements are executed through Doctrine's secure query system
- **Access Control**: Implement proper access controls for managing cron jobs in your application
- **Validation**: All entities include comprehensive validation constraints
- **Audit Trail**: Built-in tracking provides full audit capabilities

API Reference
-------------

[](#api-reference)

### CronJob Entity

[](#cronjob-entity)

- `setName(string $name)` - Set the job name
- `setCommand(string $command)` - Set the command to execute
- `setSchedule(string $schedule)` - Set the cron expression
- `setDescription(?string $description)` - Set job description
- `setValid(bool $valid)` - Enable/disable the job

### CronSql Entity

[](#cronsql-entity)

- `setTitle(string $title)` - Set the SQL job title
- `setSqlStatement(string $sql)` - Set the SQL query to execute
- `setCronExpression(string $expression)` - Set the cron expression
- `setValid(bool $valid)` - Enable/disable the SQL job

Testing
-------

[](#testing)

Run the test suite:

```
./vendor/bin/phpunit packages/doctrine-cron-job-bundle/tests
```

All tests pass with 100% coverage:

- ✅ Entity Tests (CronJob, CronSql)
- ✅ Provider Tests (DoctrineProvider, CronSqlProvider)
- ✅ Dependency Injection Tests
- ✅ Bundle Configuration Tests

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Ensure all tests pass
6. Submit a pull request

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Author
------

[](#author)

**Tourze** - [GitHub Organization](https://github.com/tourze)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance72

Regular maintenance activity

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~40 days

Recently: every ~47 days

Total

6

Last Release

189d ago

Major Versions

0.1.3 → 1.0.02025-11-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-doctrine-cron-job-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-doctrine-cron-job-bundle/health.svg)](https://phpackages.com/packages/tourze-doctrine-cron-job-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
