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 today

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

22

—

LowBetter than 21% of packages

Maintenance43

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

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

448d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7271069?v=4)[Eelan](/maintainers/Eelan)[@Eelan](https://github.com/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

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-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.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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