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

ActiveLibrary

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

Doctrine extension for PHPrimitives.

1.0.0(1mo ago)00MITPHP

Since Mar 11Pushed 1mo 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 1mo ago

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

34

—

LowBetter than 77% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

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

59d 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

[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)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k4](/packages/elgg-elgg)[neos/flow

Flow Application Framework

862.0M449](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)[rias/statamic-redirect

28298.4k](/packages/rias-statamic-redirect)

PHPackages © 2026

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