PHPackages                             xthiago/id-value-object - 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. xthiago/id-value-object

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

xthiago/id-value-object
=======================

A Value Object (VO) for Object Identity (ID). Includes a Doctrine DBAL type for persistence.

1.1.0(2y ago)28.4k1MITPHPPHP &gt;= 7.2

Since Jun 11Pushed 2y ago2 watchersCompare

[ Source](https://github.com/xthiago/id-value-object)[ Packagist](https://packagist.org/packages/xthiago/id-value-object)[ RSS](/packages/xthiago-id-value-object/feed)WikiDiscussions main Synced 1mo ago

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

Id Value Object
===============

[](#id-value-object)

PHP library to make working with object identity (ID) easier and fun!

In short: You shouldn't rely on database mechanisms to generate IDs. Also, you shouldn't manipulate scalar values (usual int) over all the application. Wherever you need to generate an ID, use this ID value object.

Features
--------

[](#features)

### UUID v4

[](#uuid-v4)

The library automatically generates UUID v4 as ID. You will not rely on persistence mechanism and flush operations to generate identity.

### Integration with Doctrine

[](#integration-with-doctrine)

The library comes with a Doctrine DBAL Type which allows you to map the Id value object as an Doctrine Entity attribute.

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

[](#requirements)

This library requires PHP &gt;= 7.2.

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

[](#installation)

Use [composer](https://getcomposer.org/) to install the library.

```
composer install xthiago/id-value-object
```

### Doctrine

[](#doctrine)

To make use of Doctrine integration for persistence you have to configure the Doctrine DBAL Type given by this package.

#### Standalone Doctrine

[](#standalone-doctrine)

You must register the DBAL Type in your application boostrap like following:

```
