PHPackages                             dobryprogramator/doctrine-safe-types - 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. dobryprogramator/doctrine-safe-types

ActiveLibrary[Database &amp; ORM](/categories/database)

dobryprogramator/doctrine-safe-types
====================================

Doctrine types for thecodingmachine/safe package

v2.0.0(10mo ago)211.3k↓42.2%3MITPHPPHP ^8.1

Since Apr 12Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/Holicz/DoctrineSafeTypes)[ Packagist](https://packagist.org/packages/dobryprogramator/doctrine-safe-types)[ RSS](/packages/dobryprogramator-doctrine-safe-types/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

Doctrine Safe Types
===================

[](#doctrine-safe-types)

Library implementing [thecodingmachine/safe](https://github.com/thecodingmachine/safe) `DateTime` and `DateTimeImmutable` into Doctrine.

Motivation
==========

[](#motivation)

In PHP &gt;= 7.4 when you use Doctrine's types and Safe property type you'll get into trap of error `Typed property App\Entity\User::$birthDate must be an instance of Safe\DateTimeImmutable, DateTimeImmutable used`.

For example this entity will generate the mentioned error:

```
// src/Entity/User.php
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Safe\DateTimeImmutable as SafeDateTimeImmutable;

/**
 * @ORM\Entity
 */
class User
{
    ...

    /**
     * @ORM\Column(type="date_immutable")
     */
    private SafeDateTimeImmutable $birthday;

    ...

    public function setBirthday(SafeDateTimeImmutable $birthday): void
    {
        $this->birthday = $birthday;
    }

    public function getBirthday(): SafeDateTimeImmutable
    {
        return $this->birthday;
    }
}
```

This library provides safe doctrine types. The annotation would transform from `@ORM\Column(type="date_immutable")`into `@ORM\Column(type="safe_date_immutable")`

Installation
============

[](#installation)

```
composer require dobryprogramator/doctrine-safe-types

```

Put following configuration into `config/packages/doctrine.yaml`:

```
doctrine:
    dbal:
        ...
        types:
            safe_date: DobryProgramator\DoctrineSafeTypes\Type\SafeDateType
            safe_date_immutable: DobryProgramator\DoctrineSafeTypes\Type\SafeDateImmutableType
            safe_datetime: DobryProgramator\DoctrineSafeTypes\Type\SafeDateTimeType
            safe_datetime_immutable: DobryProgramator\DoctrineSafeTypes\Type\SafeDateTimeImmutableType
            safe_datetimetz: DobryProgramator\DoctrineSafeTypes\Type\SafeDateTimeTzType
            safe_datetimetz_immutable: DobryProgramator\DoctrineSafeTypes\Type\SafeDateTimeTzImmutableType
            safe_time: DobryProgramator\DoctrineSafeTypes\Type\SafeTimeType
            safe_time_immutable: DobryProgramator\DoctrineSafeTypes\Type\SafeTimeImmutableType
```

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance53

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~633 days

Total

4

Last Release

326d ago

Major Versions

v1.0.2 → v2.0.02025-06-26

PHP version history (3 changes)1.0.0PHP ^7.1

v1.0.1PHP ^7.1|^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7330572?v=4)[Lukáš Holeczy](/maintainers/Holicz)[@Holicz](https://github.com/Holicz)

---

Top Contributors

[![Holicz](https://avatars.githubusercontent.com/u/7330572?v=4)](https://github.com/Holicz "Holicz (6 commits)")[![drmax-lukasholeczy](https://avatars.githubusercontent.com/u/93594520?v=4)](https://github.com/drmax-lukasholeczy "drmax-lukasholeczy (1 commits)")[![Khartir](https://avatars.githubusercontent.com/u/5592420?v=4)](https://github.com/Khartir "Khartir (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dobryprogramator-doctrine-safe-types/health.svg)

```
[![Health](https://phpackages.com/badges/dobryprogramator-doctrine-safe-types/health.svg)](https://phpackages.com/packages/dobryprogramator-doctrine-safe-types)
```

###  Alternatives

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58723.9M36](/packages/scienta-doctrine-json-functions)[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4485.3M4](/packages/martin-georgiev-postgresql-for-doctrine)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[worksome/foggy

Foggy is a tool for making database dumps with some data removed/changed.

26571.7k1](/packages/worksome-foggy)

PHPackages © 2026

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