PHPackages                             eelan/doctrine-traits - 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. eelan/doctrine-traits

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

eelan/doctrine-traits
=====================

A collection of traits for Doctrine entities.

0.0.2(1y ago)014MITPHP

Since Apr 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Eelan/doctrine-traits)[ Packagist](https://packagist.org/packages/eelan/doctrine-traits)[ RSS](/packages/eelan-doctrine-traits/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Doctrine Entity Traits · [![License](https://camo.githubusercontent.com/a2dd0919ee6152cba2a59d61b91d1363745846c7ac615fafb28a8841bbb3d94f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f65656c616e2f646f637472696e652d747261697473)](https://camo.githubusercontent.com/a2dd0919ee6152cba2a59d61b91d1363745846c7ac615fafb28a8841bbb3d94f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f65656c616e2f646f637472696e652d747261697473) [![PHP](https://camo.githubusercontent.com/d6aac44f81cb2e6f4e71f098a1cb4a71992f24f7bfb424f6670db8313c9a855c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d626c7565)](https://camo.githubusercontent.com/d6aac44f81cb2e6f4e71f098a1cb4a71992f24f7bfb424f6670db8313c9a855c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d626c7565) [![Symfony](https://camo.githubusercontent.com/704eabad4c74d453f58ce84b42cf11ca485936a991af1f4990585767edd70745/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d436f6d70617469626c652d627269676874677265656e)](https://camo.githubusercontent.com/704eabad4c74d453f58ce84b42cf11ca485936a991af1f4990585767edd70745/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d436f6d70617469626c652d627269676874677265656e)
=======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#doctrine-entity-traits----)

Reusable PHP traits for Doctrine entities, designed for Symfony projects.

This library provides a collection of common traits to reduce boilerplate code when working with Doctrine ORM.

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require eelan/doctrine-traits
```

> ⚠️ If the package is not yet published on Packagist, you can include the GitHub repository manually in your `composer.json`.

---

🧱 Available Traits
------------------

[](#-available-traits)

### `Eelan\DoctrineTraits\Common`

[](#eelandoctrinetraitscommon)

- `IdTrait` – Auto-increment integer ID
- `TimestampTrait` – `createdAt`, `updatedAt` (with lifecycle callbacks)
- `SoftDeleteTrait` – `deletedAt`, with `delete()` and `restore()` methods

### `Eelan\DoctrineTraits\Contact`

[](#eelandoctrinetraitscontact)

- `PhoneTrait` – `phone`
- `EmailTrait` – `email`

### `Eelan\DoctrineTraits\Personal`

[](#eelandoctrinetraitspersonal)

- `NameTrait` – `firstName`, `lastName`
- `GenderTrait` – `gender` (based on enum `Gender`: `MALE`, `FEMALE`, `OTHER`, `UNKNOWN`)
- `BirthTrait` – `birthDate`, `birthPlace`

### `Eelan\DoctrineTraits\Location`

[](#eelandoctrinetraitslocation)

- `AddressTrait` – `streetName`, `streetNumber`, `postalCode`, `city`
- `ExtendedAddressTrait` – extends `AddressTrait` and adds `region`, `country`
- `GpsCoordinateTrait` – `latitude`, `longitude`, and grouped coordinate helpers

---

🛠 Usage
-------

[](#-usage)

In your Doctrine entity:

```
use Eelan\DoctrineTraits\Common\IdTrait;
use Eelan\DoctrineTraits\Location\AddressTrait;
use Eelan\DoctrineTraits\Contact\EmailTrait;

class Person
{
    use IdTrait;
    use AddressTrait;
    use EmailTrait;

    // your custom fields...
}
```

All fields are mapped using PHP 8+ attributes (`#[ORM\Column(...)]`).

---

🧪 Example Entity
----------------

[](#-example-entity)

See [examples/Person.php](examples/Person.php) for a complete example using all traits.

---

📄 License
---------

[](#-license)

This project is licensed under the MIT License.
See the [LICENSE](LICENSE) file for details.

---

🙌 Contributions
---------------

[](#-contributions)

Contributions are welcome!
Feel free to open an issue or submit a pull request with new traits or improvements.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance47

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity28

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

Every ~4 days

Total

2

Last Release

391d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56e9634a33e0c81e0afbd8d50418cbcb43b2ed685e054afe645b0a952b00bf77?d=identicon)[Eelan](/maintainers/Eelan)

---

Top Contributors

[![Eelan](https://avatars.githubusercontent.com/u/7271069?v=4)](https://github.com/Eelan "Eelan (19 commits)")

### Embed Badge

![Health badge](/badges/eelan-doctrine-traits/health.svg)

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

###  Alternatives

[scienta/doctrine-json-functions

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

58523.9M35](/packages/scienta-doctrine-json-functions)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[pixelfederation/doctrine-resettable-em-bundle

Symfony bundle for decorating default entity managers using a resettable decorator.

20113.5k](/packages/pixelfederation-doctrine-resettable-em-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

813.1k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

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