PHPackages                             codeage/entitygenerator - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. codeage/entitygenerator

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

codeage/entitygenerator
=======================

Prettify your source code using model-entity-manager layer architecture.

1.2.1(10y ago)338MITPHP

Since Oct 26Pushed 10y ago3 watchersCompare

[ Source](https://github.com/DevSeqe/EntityGenerator)[ Packagist](https://packagist.org/packages/codeage/entitygenerator)[ RSS](/packages/codeage-entitygenerator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

EntityGenerator by CodeAge
==========================

[](#entitygenerator-by-codeage)

About
-----

[](#about)

I wrote this bundle to simplify my life when creating new Entity in **Symfony2** project. I was using architecture of *"3 layers"* which split your ORM logic into few files:

- **Model** - Contains only fields data and its getters and setters (and add, or remove if needed :D )
- **Entity** - Main file that is used to create Entity object, this file store internal Entity logic. eg. when you want to modify your data in some way.
- **Manager** - And the Manager file which should be treated as *"Repository"* of given Entity and you should put here every QueryBuilder that concerns it.

For now this bundle supports mapping only in **XML** format. I think it's good practice to separate all these layers to improve readability of your code.

What is more important, every Manager gets it own Service so you are able to call it in easy way. More about it in **Usage** section.

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

[](#installation)

Easy as pie :) Add to your **composer.json** file in require section:

```
"codeage/entitygenerator": "1.*"
```

And update your vendors!

Now the only thing left to do is enable this bundle in your **AppKernel** file, to do it, add:

```
new CodeAge\EntityGeneratorBundle\EntityGeneratorBundle(),
```

---

As of version **1.1.0** traits were added to AbstractEntity in order to use methods (that I will add someday :) ) even when you cannot extend AbstractEntity for some reason, eg. if you are using FOSUserBundle and you need to extend their User Entity.

---

Usage
-----

[](#usage)

To create new entity use command below:

```
$ php app/console ca:entity:generate

#for Symfony3
$ php bin/console ca:entity:generate
```

Then you will be asked about name of your new entity, but you need to proceed it with bundle name in which it will be created (Command should autocomplete name of bundle :) ). eg.

```
UserBundle:User
```

Where **UserBunlde** is bundle name and **User** is your new entity name.

From now on, you will be asked to provide field name, its type (default is string) and its parameters. String for example can be configured with length and nullable value.

There is also *"entity"* type which is used to create relation field. (**Note:** For now only one-direction relations are available)

When you add all needed fields you will be asked to confirm generation of your entity, and several files will be created in your bundle directory (as described in **about** section :) )

In your controller you can now call your manager in this way:

```
function indexAction($id){
    $userManager = $this->get(UserManager::SERVICE); /* @var $userManager UserManager */
    $user = $userManager->find($id); /* @var $user User */
}
```

And that's it! As I said before, manager is used just like repository, so you can create some usefull queries in there to use insetad of "find" like in example here, but you can also use all respoitory-like methods as well eg.

- findBy
- findAll
- findOneBy

And what about insertions, updates and deletes?

#### Insert

[](#insert)

```
$userManager = $this->get(UserManager::SERVICE); /* @var $userManager UserManager */
$user = new User();
$user->setName('SomeNameOFUser');

$userManager->persist($user)
       ->flush();
```

#### Update

[](#update)

```
$userManager = $this->get(UserManager::SERVICE); /* @var $userManager UserManager */
$user = $userManager->find($id); /* @var $user User */
//Assume that there is a user with this id :)

$user->setName('NewNameForUser');
$userManager->update($user); //Done! But you can pass false as second parameter to disable force-flush :)
```

#### Delete/Remove

[](#deleteremove)

```
$userManager = $this->get(UserManager::SERVICE); /* @var $userManager UserManager */
$user = $userManager->find($id); /* @var $user User */
$userManager->remove($user); //Done! But you still can disable force-flush
```

### Planned changes:

[](#planned-changes)

- Use **traits** instead of simple inheritance, for simplifying implementation of FOSUserBundle :)
- Printing list of all possible types for field
- Print all entity configuration when asking if user confirm generation
- Ability to modify field after adding it
- Get all types from DBAL
- Enum types generator

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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 ~19 days

Total

4

Last Release

3800d ago

### Community

Maintainers

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

---

Top Contributors

[![DevSeqe](https://avatars.githubusercontent.com/u/11227906?v=4)](https://github.com/DevSeqe "DevSeqe (9 commits)")

---

Tags

generator command symfony model entity manager service

### Embed Badge

![Health badge](/badges/codeage-entitygenerator/health.svg)

```
[![Health](https://phpackages.com/badges/codeage-entitygenerator/health.svg)](https://phpackages.com/packages/codeage-entitygenerator)
```

PHPackages © 2026

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