PHPackages                             chamber-orchestra/doctrine-clock-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. [Database &amp; ORM](/categories/database)
4. /
5. chamber-orchestra/doctrine-clock-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

chamber-orchestra/doctrine-clock-bundle
=======================================

Automatic Doctrine ORM timestamps using PHP attributes and Symfony Clock. Provides #\[CreateTimestamp\] and #\[UpdateTimestamp\] attributes with ready-to-use entity traits for createdDatetime/updatedDatetime fields.

v8.0.2(2mo ago)1553↓20%2MITPHPPHP ^8.5CI passing

Since Jan 4Pushed 2mo agoCompare

[ Source](https://github.com/chamber-orchestra/doctrine-clock-bundle)[ Packagist](https://packagist.org/packages/chamber-orchestra/doctrine-clock-bundle)[ RSS](/packages/chamber-orchestra-doctrine-clock-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (4)Used By (2)

[![PHP Composer](https://github.com/chamber-orchestra/doctrine-clock-bundle/actions/workflows/php.yml/badge.svg)](https://github.com/chamber-orchestra/doctrine-clock-bundle/actions/workflows/php.yml)[![codecov](https://camo.githubusercontent.com/ed8cbcf0ec32e6ae8b61d5843a602cd87e400f99afcf343b141c08ba50899b99/68747470733a2f2f636f6465636f762e696f2f67682f6368616d6265722d6f72636865737472612f646f637472696e652d636c6f636b2d62756e646c652f67726170682f62616467652e737667)](https://codecov.io/gh/chamber-orchestra/doctrine-clock-bundle)[![PHPStan](https://camo.githubusercontent.com/71936661c994bdd70ec588a6771c605f8584906d8054c5d607a3bcc6bd943f3c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6d61782d627269676874677265656e)](https://phpstan.org/)[![Latest Stable Version](https://camo.githubusercontent.com/a966b279e2a830ab32524807cff85e7885e7daeef7e0f093fd233e6ce332bdc3/68747470733a2f2f706f7365722e707567782e6f72672f6368616d6265722d6f72636865737472612f646f637472696e652d636c6f636b2d62756e646c652f76)](https://packagist.org/packages/chamber-orchestra/doctrine-clock-bundle)[![License](https://camo.githubusercontent.com/53b8eaf9a05fe35839ee556a25e802e7eb2d2a2fa614e6aa897806630849807f/68747470733a2f2f706f7365722e707567782e6f72672f6368616d6265722d6f72636865737472612f646f637472696e652d636c6f636b2d62756e646c652f6c6963656e7365)](https://packagist.org/packages/chamber-orchestra/doctrine-clock-bundle)[![PHP 8.5](https://camo.githubusercontent.com/699b5e675b37d1256e54ec33a27ecfad75891142c2791f3ee3292c553cb31994/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352d626c75653f6c6f676f3d706870)](https://camo.githubusercontent.com/699b5e675b37d1256e54ec33a27ecfad75891142c2791f3ee3292c553cb31994/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352d626c75653f6c6f676f3d706870)[![Doctrine ORM 3](https://camo.githubusercontent.com/b52372e263348ab9a511539d5b6382c4628572d9ffc3bc4df8b175d704fc24c3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f637472696e652532304f524d2d332d6f72616e67653f6c6f676f3d646f637472696e65)](https://camo.githubusercontent.com/b52372e263348ab9a511539d5b6382c4628572d9ffc3bc4df8b175d704fc24c3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f637472696e652532304f524d2d332d6f72616e67653f6c6f676f3d646f637472696e65)[![Symfony 8](https://camo.githubusercontent.com/a7d902ab1b809ccff2eaa21df5aadd13f1b13e22e4e4c49f40d020b918f48e05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d382d707572706c653f6c6f676f3d73796d666f6e79)](https://camo.githubusercontent.com/a7d902ab1b809ccff2eaa21df5aadd13f1b13e22e4e4c49f40d020b918f48e05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d382d707572706c653f6c6f676f3d73796d666f6e79)

Doctrine Clock Bundle
=====================

[](#doctrine-clock-bundle)

A Symfony bundle that automatically manages `createdDatetime` and `updatedDatetime` fields on Doctrine ORM entities using PHP attributes and `symfony/clock` `DatePoint`.

Drop `#[CreateTimestamp]` / `#[UpdateTimestamp]` on any entity property (or use the provided traits) and the bundle handles the rest -- no interfaces, no manual event wiring.

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

[](#requirements)

- PHP 8.5+
- Symfony 8.0
- Doctrine ORM 3.6+

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

[](#installation)

```
composer require chamber-orchestra/doctrine-clock-bundle
```

If you are not using Symfony Flex, register the bundles manually:

```
// config/bundles.php
return [
    ChamberOrchestra\MetadataBundle\ChamberOrchestraMetadataBundle::class => ['all' => true],
    ChamberOrchestra\DoctrineClockBundle\ChamberOrchestraDoctrineClockBundle::class => ['all' => true],
];
```

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

[](#quick-start)

Use the provided traits to add timestamp fields to your entities:

```
use ChamberOrchestra\DoctrineClockBundle\Entity\TimestampTrait;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class Article
{
    use TimestampTrait; // adds createdDatetime + updatedDatetime

    // ... your fields
}
```

That's it. On `persist`, both fields are set to the current `DatePoint`. On `update`, only `updatedDatetime` is refreshed. Manually pre-populated values are preserved on insert.

Available Traits
----------------

[](#available-traits)

TraitFieldsColumn precision`TimestampTrait``createdDatetime` + `updatedDatetime`seconds`TimestampCreateTrait``createdDatetime` onlyseconds`TimestampUpdateTrait``updatedDatetime` onlyseconds`PrecisedTimestampTrait``createdDatetime` + `updatedDatetime`microseconds (scale: 6)`PrecisedTimestampCreateTrait``createdDatetime` onlymicroseconds (scale: 6)`PrecisedTimestampUpdateTrait``updatedDatetime` onlymicroseconds (scale: 6)Using Attributes Directly
-------------------------

[](#using-attributes-directly)

If you prefer full control over your entity properties, use the attributes without traits:

```
use ChamberOrchestra\DoctrineClockBundle\Mapping\Attribute\CreateTimestamp;
use ChamberOrchestra\DoctrineClockBundle\Mapping\Attribute\UpdateTimestamp;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Clock\DatePoint;

#[ORM\Entity]
class Article
{
    #[CreateTimestamp]
    #[ORM\Column(type: 'date_point', nullable: false)]
    private DatePoint $createdAt;

    #[UpdateTimestamp]
    #[ORM\Column(type: 'date_point', nullable: false)]
    private DatePoint $modifiedAt;

    // ... getters, setters
}
```

Multiple fields with the same attribute are supported -- e.g. two `#[CreateTimestamp]` properties will both be set on insert.

Behaviour
---------

[](#behaviour)

Event`#[CreateTimestamp]``#[UpdateTimestamp]``prePersist`Set if `null`Set if `null``preUpdate`Not touchedAlways overwrittenCustom DBAL Types (Optional)
----------------------------

[](#custom-dbal-types-optional)

The bundle ships DBAL type overrides for improved timestamp precision and decimal handling:

```
# config/packages/doctrine.yaml
doctrine:
    dbal:
        types:
            datetime: ChamberOrchestra\DoctrineClockBundle\Type\DateTimeType
            datetime_immutable: ChamberOrchestra\DoctrineClockBundle\Type\DateTimeImmutableType
            decimal: ChamberOrchestra\DoctrineClockBundle\Type\DecimalType
```

Development
-----------

[](#development)

```
composer test        # PHPUnit
composer analyse     # PHPStan (level max)
composer cs-check    # PHP CS Fixer (dry-run)
composer cs-fix      # PHP CS Fixer (apply)
```

License
-------

[](#license)

MIT -- see [LICENSE](LICENSE).

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance84

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

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 ~24 days

Total

3

Last Release

78d ago

PHP version history (2 changes)v8.0.1PHP ^8.4

v8.0.2PHP ^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/44037eb1c8dc2c4fa9871ac213653f33e22a9348dcec7132df07cc71933f2a2e?d=identicon)[wtorsi](/maintainers/wtorsi)

---

Top Contributors

[![wtorsi](https://avatars.githubusercontent.com/u/2115840?v=4)](https://github.com/wtorsi "wtorsi (2 commits)")

---

Tags

auto-timestampcreated-atdatepointdoctrinedoctrine-ormphpphp-attributessymfonysymfony-bundlesymfony-clocktimestampupdated-atsymfonyclockormdoctrineattributestimestampcreated-atupdated-atdatepointauto-timestamp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chamber-orchestra-doctrine-clock-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/chamber-orchestra-doctrine-clock-bundle/health.svg)](https://phpackages.com/packages/chamber-orchestra-doctrine-clock-bundle)
```

###  Alternatives

[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)[omines/datatables-bundle

Symfony DataTables Bundle with native Doctrine ORM, Elastica and MongoDB support

2851.4M6](/packages/omines-datatables-bundle)[goodwix/doctrine-json-odm

JSON Object-Document Mapping bundle for Symfony and Doctrine

2226.0k](/packages/goodwix-doctrine-json-odm)[nemo64/dbal-rds-data

rds-data driver for doctrine dbal

2713.2k](/packages/nemo64-dbal-rds-data)

PHPackages © 2026

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