PHPackages                             a5sys/doctrine-trait-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. a5sys/doctrine-trait-bundle

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

a5sys/doctrine-trait-bundle
===========================

V2.0.0(7y ago)65.8k↓66.7%2[2 issues](https://github.com/A5sys/DoctrineTraitBundle/issues)MITPHPPHP ^7.1

Since Apr 15Pushed 7y ago3 watchersCompare

[ Source](https://github.com/A5sys/DoctrineTraitBundle)[ Packagist](https://packagist.org/packages/a5sys/doctrine-trait-bundle)[ RSS](/packages/a5sys-doctrine-trait-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (10)Used By (0)

DoctrineTraitBundle
===================

[](#doctrinetraitbundle)

Generate the entities stub methods in a trait

The generated traits contains the getters/setters generated by the doctrine generator. The trait should be used in your entity.

Benefits
========

[](#benefits)

Your entities contains only the usefull information:

- The doctrine columns and relationships
- The getters/setters that have been modified
- The custom methods

All basics getters/setters are in the trait.

Composer
========

[](#composer)

Use composer to get the bundle

```
composer require --dev "a5sys/doctrine-trait-bundle"

```

Activate the bundle
===================

[](#activate-the-bundle)

In the AppKernel, activate the bundle for the dev environment

```
    if (in_array($this->getEnvironment(), array('dev'))) {
        ...
        $bundles[] = new A5sys\DoctrineTraitBundle\DoctrineTraitBundle();
    }

```

Usage
=====

[](#usage)

Generate traits
---------------

[](#generate-traits)

Run the command

```
    php app/console generate:doctrine:traits AppBundle\\Entity

```

Or this one if you want to act on a single entity

```
    php app/console generate:doctrine:traits "AppBundle:MyEntity"

```

Those commands will generate the trait(s) in the /src/AppBundle/Entity/Traits directory

Use custom method
-----------------

[](#use-custom-method)

- Go in the trait related to your entity
- Cut the method
- Go in your entity
- Paste the method
- Update the method
- The command will not re-generate this method because it is already defined in entity

Exemple
-------

[](#exemple)

- Create your entity (User) without the getters/setters
- Run the command
- Add the trait to your entity
- You are done

### The entity

[](#the-entity)

```
    namespace AppBundle/Entity;

    class User
    {
        use AppBundle/Entity/Traits/UserTrait;

        /**
         * @ORM\Id
         * @ORM\GeneratedValue
         * @ORM\Column(type="integer", nullable=false)
         */
        protected $id;

        /**
         * @ORM\Column(type="string", length=50, nullable=false)
         */
        protected $name;
    }

```

### The trait

[](#the-trait)

```
    namespace AppBundle/Entity/Traits;

    /**
     * User
     */
    trait UserTrait
    {

        /**
         *
         * @param integer $id
         */
        public function setId($id)
        {
            $this->id = $id;
        }

        /**
         *
         * @return integer
         */
        public function getId()
        {
            return $this->id;
        }

        /**
         *
         * @param string $name
         */
        public function setName($name)
        {
            $this->name = $name;
        }

        /**
         * Get the name
         *
         * @return string
         */
        public function getName()
        {
            return $this->name;
        }
    }

```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~138 days

Recently: every ~168 days

Total

7

Last Release

2848d ago

Major Versions

V1.0.5 → V2.0.02018-07-23

PHP version history (2 changes)V1.0.0PHP &gt;=5.4.0

V2.0.0PHP ^7.1

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/3a644d41501105bc7aded710d1682ac2a3abdceaf9c02e97d1cb1d6e2607c9d9?d=identicon)[ttx-a5](/maintainers/ttx-a5)

---

Top Contributors

[![thomasbeaujean](https://avatars.githubusercontent.com/u/5817919?v=4)](https://github.com/thomasbeaujean "thomasbeaujean (6 commits)")[![arnaudgoulpeau](https://avatars.githubusercontent.com/u/14837692?v=4)](https://github.com/arnaudgoulpeau "arnaudgoulpeau (3 commits)")

---

Tags

doctrinegetterssetterssymfony-bundle

### Embed Badge

![Health badge](/badges/a5sys-doctrine-trait-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/a5sys-doctrine-trait-bundle/health.svg)](https://phpackages.com/packages/a5sys-doctrine-trait-bundle)
```

###  Alternatives

[hautelook/alice-bundle

Symfony bundle to manage fixtures with Alice and Faker.

19519.4M34](/packages/hautelook-alice-bundle)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[ambta/doctrine-encrypt-bundle

Symfony 2 bundle which allows to encrypt data in database with some encrypt algorithm

77275.7k](/packages/ambta-doctrine-encrypt-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)[heymoon/doctrine-psql-enum

Store PHP native enums as PostgeSQL custom enum types

254.9k](/packages/heymoon-doctrine-psql-enum)

PHPackages © 2026

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