PHPackages                             somnambulist/value-object-doctrine-mappings - 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. somnambulist/value-object-doctrine-mappings

Abandoned → [somnambulist/domain](/?search=somnambulist%2Fdomain)ArchivedLibrary[Database &amp; ORM](/categories/database)

somnambulist/value-object-doctrine-mappings
===========================================

A collection of mapping files for the value-objects included in: somnambulist/value-objects

1.5.1(8y ago)01.7kMITPHPPHP &gt;7

Since Jun 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/dave-redfern/somnambulist-value-objects-doctrine-mappings)[ Packagist](https://packagist.org/packages/somnambulist/value-object-doctrine-mappings)[ RSS](/packages/somnambulist-value-object-doctrine-mappings/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (8)Versions (11)Used By (0)

Moved to
==============================================================

[](#moved-to-httpsgithubcomdave-redfernsomnambulist-domain)

This repository has been archived. Please update to the combined package.s

Doctrine Mappings for Value Objects and Enumerations
----------------------------------------------------

[](#doctrine-mappings-for-value-objects-and-enumerations)

Provides a basic set of mapping information for the somnambulist/value-objects library for use with Doctrine. Mappings are available for Doctrine (.dcm.yml) and Symfony (.orm.yml). The mappings are symlinked from symfony to doctrine.

A `Bootstrapper` is included for automatically registering the value-object enumerations as Doctrine types.

### Requirements

[](#requirements)

- PHP 7+
- Doctrine ORM 2.5+

### Installation

[](#installation)

Install using composer, or checkout / pull the files from github.com.

- composer require somnambulist/value-object-doctrine-mappings

### Usage

[](#usage)

Copy or link the mapping files to your project in the Doctrine configuration. These are needed per entity manager. It is highly recommended to extend the value-objects to your own and then copy and adapt the mappings as you need.

Remember: value-objects are part of your domain model and should be treated with care.

**Note:** enumerations are used in these mappings.

#### Register Enumeration Handlers

[](#register-enumeration-handlers)

To register the enumeration handlers add the following to your applications bootstrap code (e.g.: AppBundle::boot or AppServiceProvider::register|boot):

```
Somnambulist\Doctrine\Bootstrapper::registerEnumerations();

```

This will pre-register the following enumerations:

- Geography\\CountryCode
- Geography\\Srid
- Measure\\AreaUnit
- Measure\\DistanceUnit
- Money\\CurrencyCode

In addition extra helpers are registered to allow the Country and Currency value objects to be used as enumerations. These are stored using the CountryCode and CurrencyCode values and restored using the `::create()` method.

#### Register Custom Types

[](#register-custom-types)

Custom types are included for:

- datetime
- datetimetz
- date
- time
- json
- jsonb
- json\_collection

The date types override the default Doctrine types and uses the VO DateTime that is an extended DateTimeImmutable object.

json, jsonb and json\_collection are equivalent and allow JSON data to be converted to and from a Collection object instead of a plain array.

To register the types add the following to your application bootstrap:

```
Somnambulist\Doctrine\Bootstrapper::registerTypes();

```

#### Mapping Files

[](#mapping-files)

To use the types and enumerations, in your mapping files set the type appropriately:

```
fields:
    createdAt:
        type: datetime

    attributes:
        type: json

    country:
        type: Somnambulist\ValueObjects\Types\Geography\Country

    currency:
        type: Somnambulist\ValueObjects\Types\Money\Currency
```

To use the value-objects:

```
embedded:
    contact:
        class: Somnambulist\ValueObjects\Types\Identity\EmailAddress

    homepage:
        class: Somnambulist\ValueObjects\Types\Web\Url
```

Or in XML format:

```

```

When using embeddables, be sure to have added the necessary mapping files.

### Configuring Types for Symfony

[](#configuring-types-for-symfony)

Within a Symfony project, add a new mapping area to your orm configuration within the `doctrine` section:

```
doctrine:
    # snip ...
    orm:
        mappings:
            App\Entities:
                mapping:   true
                type:      yml
                dir:       '%kernel.project_dir%/config/mappings/entities'
                is_bundle: false
                prefix:    App\Entities

            Somnambulist\ValueObjects\Types:
                mapping:   true
                type:      xml
                dir:       '%kernel.project_dir%/config/mappings/somnambulist'
                is_bundle: false
                prefix:    Somnambulist\ValueObjects\Types
```

Then either copy or symlink the appropriate config files from vendor config folder to your projects mapping config section. If you have different requirements for field type, copy and update as appropriate. It is recommended to copy and not link the mapping files to avoid issues with this library changing.

### Links

[](#links)

- [Doctrine](http://doctrine-project.org)
- [Enumeration Bridge](https://github.com/dave-redfern/somnambulist-doctrine-enum-bridge)
- [Value Objects](https://github.com/dave-redfern/somnambulist-value-objects)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

Established project with proven stability

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

Total

10

Last Release

3112d ago

### Community

Maintainers

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

---

Top Contributors

[![dave-redfern](https://avatars.githubusercontent.com/u/1477147?v=4)](https://github.com/dave-redfern "dave-redfern (4 commits)")

---

Tags

doctrineenumerationmappingsvalue-objectdoctrinevalue objectsddddoctrine mapping

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/somnambulist-value-object-doctrine-mappings/health.svg)

```
[![Health](https://phpackages.com/badges/somnambulist-value-object-doctrine-mappings/health.svg)](https://phpackages.com/packages/somnambulist-value-object-doctrine-mappings)
```

###  Alternatives

[scienta/doctrine-json-functions

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

58523.9M36](/packages/scienta-doctrine-json-functions)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[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)[flow-php/doctrine-dbal-bulk

Bulk inserts and updates for Doctrine DBAL

14295.2k1](/packages/flow-php-doctrine-dbal-bulk)

PHPackages © 2026

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