PHPackages                             hostnet/entity-plugin-lib - 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. hostnet/entity-plugin-lib

ActiveComposer-plugin[Database &amp; ORM](/categories/database)

hostnet/entity-plugin-lib
=========================

Installer for all the Hostnet Doctrine entity libraries

4.0.2(1y ago)8141.1k↓13.5%8MITPHPPHP ^8.1CI passing

Since Apr 2Pushed 1y ago4 watchersCompare

[ Source](https://github.com/hostnet/entity-plugin-lib)[ Packagist](https://packagist.org/packages/hostnet/entity-plugin-lib)[ RSS](/packages/hostnet-entity-plugin-lib/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (48)Used By (0)

entity-plugin-lib
=================

[](#entity-plugin-lib)

### The problem

[](#the-problem)

The Hostnet Entity Composer plugin was developed to solve several problems experienced with plain usage of the Doctrine ORM. Although our solution is inspired on working with doctrine it is perfectly usable for every other way of persisting entities. The problems we came across are:

- Entities became really big;
- Entities were shared between applications and these applications inherited functionality they were not allowed to use;
- Knowledge areas like calculating discounts were spread through the model and not grouped together;
- Misuse of inheritance to prevent code duplication.

To solve our problem we borrowed some ideas from another realm of software development, since we felt we were hitting the boundaries of [Object Oriented Programming](http://148.204.64.201/paginas%20anexas/POO/papers/papers%20de%20POO/p96-pokkunuri.pdf "Object Oriented Programming") and sought for more modularization. We used the ideas behind [Aspect Oriented Programming](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.95.2500&rep=rep1&type=pdf "Aspect-oriented programming") to solve our problems.

The basic concept: Entities are grouped by responsibility in packages. This plugin links the packages together.

This is awesome for you if;

- You maintain an open source project that includes entities, that you would like people to expand on.
- You have a database and various applications accessing different (but related) subsets of that database.
- Or searching to glue something yourself.

If you do not belong in one of those groups, be careful since this might not be what you want.

### Example

[](#example)

One application needs to know about `Clients`, but is unaware of the concept of a `Contract`. Another application requires access to both of them. So in one application, you'd want to be able to call `$client->getContracts()`. But in the other, you'd prefer to not know about contracts at all!

With this plugin you can create one package that is purely `Client` focussed, and another that is `Contract` focussed, and that injects the additional functionality (like `getContracts`) to `Client`.

### Usage

[](#usage)

#### Creating an extendable package

[](#creating-an-extendable-package)

- Create a composer package to put your entities in.
- Use PSR-0 or PSR-4 [autoloading](https://getcomposer.org/doc/04-schema.md#autoload) for the src/ directory.
- The package should be of [type](https://getcomposer.org/doc/04-schema.md#type) `hostnet-entity`.
- The package should require `"hostnet/entity-plugin-lib": "2.*"`
- Create one entity, say `Page`, inside a namespace that ends with `Entity`.
- Run `php composer.phar dump-autoload`. (The entity plugin hooks to this event.) This should cause some output:

```
Pass 1/3: Generating compound traits and interfaces
Pass 2/3: Preparing individual generation
Pass 3/3: Performing individual generation

```

- From your entity, use the trait generated in the `Generated/` namespace:

```
    use \Hostnet\Page\Entity\Generated\PageTraits;

```

Congratulations, you now have an extendable entity package.

#### Extending the package

[](#extending-the-package)

Follow the steps above, and

- Make sure your new package depends on the old one.
- Instead of creating the `Page` class, create a `PageTrait`.
- Run `php composer.phar update`.
- Check `vendor/your-vendor-name/your-package-name/src/Entity/Generated/PageTraits.php`. It should include a reference to your package.

### Tips

[](#tips)

If you run the composer.phar with `-v` or `-vv` or `-vvv` it will show more information.

If you want to extend an entity from your main application, you can use the `entity-bundle-dir` setting in the extra section of your composer.json.

If you do not want to generate interfaces, you can set the `generate-interfaces` setting to `false` in the extra setting of your composer.json. We will change this to being the default behaviour in a future release.

For a quick overview have a look at the [cheatsheet](https://hostnet.github.io/entity-plugin-lib/).

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance42

Moderate activity, may be stable

Popularity39

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor4

4 contributors hold 50%+ of commits

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

Recently: every ~309 days

Total

46

Last Release

462d ago

Major Versions

1.8.0 → 2.0.02016-06-09

2.2.2 → 3.0.02019-12-18

3.0.11 → 4.0.02023-05-31

PHP version history (7 changes)1.1.0PHP &gt;=5.4

1.8.0PHP &gt;=5.5

2.0.0PHP &gt;=5.6

3.0.0PHP &gt;=7.2

3.0.8PHP &gt;=7.3

4.0.0PHP ^8.0

4.0.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/65433e1ef6edb2e8f96e18614b6618c84eed20ad0de6de0d0da36a9032ec7a18?d=identicon)[hostnet](/maintainers/hostnet)

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

---

Top Contributors

[![nicoschoenmaker](https://avatars.githubusercontent.com/u/1469323?v=4)](https://github.com/nicoschoenmaker "nicoschoenmaker (15 commits)")[![yannickl88](https://avatars.githubusercontent.com/u/5468127?v=4)](https://github.com/yannickl88 "yannickl88 (14 commits)")[![nutama](https://avatars.githubusercontent.com/u/9001392?v=4)](https://github.com/nutama "nutama (6 commits)")[![janlam7](https://avatars.githubusercontent.com/u/5459235?v=4)](https://github.com/janlam7 "janlam7 (6 commits)")[![svandervlugt](https://avatars.githubusercontent.com/u/9334451?v=4)](https://github.com/svandervlugt "svandervlugt (5 commits)")[![pjordaan](https://avatars.githubusercontent.com/u/2209895?v=4)](https://github.com/pjordaan "pjordaan (5 commits)")[![linaori](https://avatars.githubusercontent.com/u/1754678?v=4)](https://github.com/linaori "linaori (5 commits)")[![hboomsma](https://avatars.githubusercontent.com/u/1465009?v=4)](https://github.com/hboomsma "hboomsma (4 commits)")[![stefanlenselink](https://avatars.githubusercontent.com/u/834562?v=4)](https://github.com/stefanlenselink "stefanlenselink (4 commits)")[![haroldiedema](https://avatars.githubusercontent.com/u/567518?v=4)](https://github.com/haroldiedema "haroldiedema (2 commits)")[![ping-localhost](https://avatars.githubusercontent.com/u/37925797?v=4)](https://github.com/ping-localhost "ping-localhost (1 commits)")[![jzeilmaker](https://avatars.githubusercontent.com/u/6861233?v=4)](https://github.com/jzeilmaker "jzeilmaker (1 commits)")[![rickprent](https://avatars.githubusercontent.com/u/2202733?v=4)](https://github.com/rickprent "rickprent (1 commits)")[![mvannes](https://avatars.githubusercontent.com/u/8969371?v=4)](https://github.com/mvannes "mvannes (1 commits)")[![StijnKlopper2k](https://avatars.githubusercontent.com/u/198602351?v=4)](https://github.com/StijnKlopper2k "StijnKlopper2k (1 commits)")[![JasperS2307](https://avatars.githubusercontent.com/u/26083805?v=4)](https://github.com/JasperS2307 "JasperS2307 (1 commits)")[![eddypouw](https://avatars.githubusercontent.com/u/8748009?v=4)](https://github.com/eddypouw "eddypouw (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hostnet-entity-plugin-lib/health.svg)

```
[![Health](https://phpackages.com/badges/hostnet-entity-plugin-lib/health.svg)](https://phpackages.com/packages/hostnet-entity-plugin-lib)
```

###  Alternatives

[api-platform/schema-generator

Various tools to generate a data model based on Schema.org vocables

4714.2M7](/packages/api-platform-schema-generator)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2592.8M263](/packages/ssch-typo3-rector)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)[chameleon-system/chameleon-base

The Chameleon System core.

1026.5k3](/packages/chameleon-system-chameleon-base)

PHPackages © 2026

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