PHPackages                             fasano/phprimitives-doctrine - 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. fasano/phprimitives-doctrine

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

fasano/phprimitives-doctrine
============================

Doctrine extension for PHPrimitives.

1.0.0(5mo ago)03MITPHP

Since Mar 11Pushed 5mo agoCompare

[ Source](https://github.com/n-fasano/phprimitives-doctrine)[ Packagist](https://packagist.org/packages/fasano/phprimitives-doctrine)[ RSS](/packages/fasano-phprimitives-doctrine/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

PHPrimitives - Doctrine
-----------------------

[](#phprimitives---doctrine)

A set of Doctrine DBAL types to map any [PHPrimitive](https://github.com/n-fasano/phprimitives) with almost no boilerplate.

### Installation

[](#installation)

```
composer require fasano/phprimitives-doctrine
```

### Creating a Custom Type

[](#creating-a-custom-type)

Extend the abstract type that matches your primitive's scalar type, then implement two methods:

```
use Fasano\PHPrimitives\Doctrine\StringPrimitiveType;

final class EmailType extends StringPrimitiveType
{
    public function getName(): string
    {
        return 'email';
    }

    protected function getPrimitiveClass(): string
    {
        return Email::class;
    }
}
```

### Registering Types

[](#registering-types)

Register your custom types, as usual:

```
use Doctrine\DBAL\Types\Type;

Type::addType('email', EmailType::class);
Type::addType('age',   AgeType::class);
Type::addType('status', StatusType::class);
```

**Symfony** — register via `config/packages/doctrine.yaml` instead:

```
doctrine:
    dbal:
        types:
            email:  Infra\Doctrine\Type\EmailType
            age:    Infra\Doctrine\Type\AgeType
            status: Infra\Doctrine\Type\StatusType
```

### Using The Types

[](#using-the-types)

Reference the type name in your `#[Column]` attribute:

```
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class User
{
    #[ORM\Column(type: 'email')]
    public Email $email;

    #[ORM\Column(type: 'age')]
    public Age $age;

    #[ORM\Column(type: 'status')]
    public Status $status;
}
```

Doctrine will call `construct()` when hydrating from the database and `deconstruct()` when persisting, so your domain invariants are enforced on every read and write.

###  Health Score

30

—

LowBetter than 61% of packages

Maintenance73

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

150d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/16bb6f7b889777bcd3237bbddd90a3707306fc1803da0bd10c3710086b8702a4?d=identicon)[nfasano](/maintainers/nfasano)

---

Top Contributors

[![n-fasano](https://avatars.githubusercontent.com/u/46872160?v=4)](https://github.com/n-fasano "n-fasano (1 commits)")

---

Tags

doctrine-dbaldoctrine-ormphpprimitive-types

### Embed Badge

![Health badge](/badges/fasano-phprimitives-doctrine/health.svg)

```
[![Health](https://phpackages.com/badges/fasano-phprimitives-doctrine/health.svg)](https://phpackages.com/packages/fasano-phprimitives-doctrine)
```

###  Alternatives

[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

11.2k4.0k](/packages/leantime-leantime)[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.

4566.0M4](/packages/martin-georgiev-postgresql-for-doctrine)[flow-php/doctrine-dbal-bulk

Bulk inserts and updates for Doctrine DBAL

14404.6k5](/packages/flow-php-doctrine-dbal-bulk)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1617.3k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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