PHPackages                             andanteproject/nullable-embeddable-bundle - 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. andanteproject/nullable-embeddable-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

andanteproject/nullable-embeddable-bundle
=========================================

A Symfony Bundle to handle nullable embeddables with Doctrine

v1.0.2(3mo ago)21MITPHPPHP ^8.1CI passing

Since Nov 12Pushed 3mo agoCompare

[ Source](https://github.com/andanteproject/nullable-embeddable-bundle)[ Packagist](https://packagist.org/packages/andanteproject/nullable-embeddable-bundle)[ RSS](/packages/andanteproject-nullable-embeddable-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (17)Versions (5)Used By (0)

[![Andante Project Logo](https://github.com/andanteproject/nullable-embeddable-bundle/raw/main/andanteproject-logo.png?raw=true)](https://github.com/andanteproject/nullable-embeddable-bundle/blob/main/andanteproject-logo.png?raw=true)

Nullable Embeddable Bundle
==========================

[](#nullable-embeddable-bundle)

#### Symfony Bundle - [AndanteProject](https://github.com/andanteproject)

[](#symfony-bundle---andanteproject)

[![Latest Version](https://camo.githubusercontent.com/f7a6fb806efafbb41ae1065d2b46da1283c367bbd44ba5f79e12da76cb0f0d53/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f616e64616e746570726f6a6563742f6e756c6c61626c652d656d6265646461626c652d62756e646c652e737667)](https://github.com/andanteproject/nullable-embeddable-bundle/releases)[![Github actions](https://github.com/andanteproject/nullable-embeddable-bundle/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/andanteproject/nullable-embeddable-bundle/actions/workflows/ci.yml/badge.svg?branch=main)[![codecov](https://camo.githubusercontent.com/c18160aef2806efdc7bc39c91ff14e107e0e697510d9a7ddb7d28057d5685ca1/68747470733a2f2f636f6465636f762e696f2f67682f616e64616e746570726f6a6563742f6e756c6c61626c652d656d6265646461626c652d62756e646c652f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/andanteproject/nullable-embeddable-bundle)[![Framework](https://camo.githubusercontent.com/7237fd8b94128ffc987a13c1331436192b15b130505ef7fa22366d9bb57e3d03/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d352e78253743362e78253743372e78253743382e782d696e666f726d6174696f6e616c3f7374796c653d666c6174266c6f676f3d73796d666f6e79)](https://camo.githubusercontent.com/7237fd8b94128ffc987a13c1331436192b15b130505ef7fa22366d9bb57e3d03/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d352e78253743362e78253743372e78253743382e782d696e666f726d6174696f6e616c3f7374796c653d666c6174266c6f676f3d73796d666f6e79)[![Php8](https://camo.githubusercontent.com/4729796bad499a5eaceab0b045404e26158a1c06bd738aaa82deca0f7a271a22/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e31253743382e352532422d696e666f726d6174696f6e616c3f7374796c653d666c6174266c6f676f3d706870)](https://camo.githubusercontent.com/4729796bad499a5eaceab0b045404e26158a1c06bd738aaa82deca0f7a271a22/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e31253743382e352532422d696e666f726d6174696f6e616c3f7374796c653d666c6174266c6f676f3d706870)[![PhpStan](https://camo.githubusercontent.com/39aab7039f5f45e3f46f9b4bca8d980192fb28e72496d6eb7cb5897f08781bfd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230392d737563636573733f7374796c653d666c6174266c6f676f3d706870)](https://camo.githubusercontent.com/39aab7039f5f45e3f46f9b4bca8d980192fb28e72496d6eb7cb5897f08781bfd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230392d737563636573733f7374796c653d666c6174266c6f676f3d706870)

A Symfony Bundle that extends [Doctrine Embeddables](https://www.doctrine-project.org/projects/doctrine-orm/en/3.5/tutorials/embeddables.html) to allow them to be nullable with **custom business logic** to precisely determine their null state, **handling null** and **uninitialized properties**, addressing a common limitation in Doctrine ORM.

Introduction
------------

[](#introduction)

[Doctrine Embeddables](https://www.doctrine-project.org/projects/doctrine-orm/en/3.5/tutorials/embeddables.html) are powerful for encapsulating value objects, but they inherently cannot be null. This bundle provides a flexible solution to this limitation by introducing the `#[NullableEmbeddable]` attribute. This attribute allows you to define custom logic, either through a dedicated [processor class](#processor-interface) or a [static anonymous function (PHP 8.5+)](#anonymous-function-processor-php-85), to determine when an embeddable object should be considered null. This enables precise control over the null state, even handling uninitialized properties safely.

The bundle works seamlessly with multiple levels of embedded objects, processing from the deepest leaf embeddable up to the root entity.

For example, a `Country` embeddable can be marked as nullable based on an uninitialized property:

```
