PHPackages                             entity-forge/entity-forge - 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. [Framework](/categories/framework)
4. /
5. entity-forge/entity-forge

ActiveLibrary[Framework](/categories/framework)

entity-forge/entity-forge
=========================

A configuration-driven PHP framework for generating entity models and building multi-tenant SaaS applications.

v2.2.0(3d ago)271MITPHPPHP ^8.3CI failing

Since Jun 15Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/vedavith/Entity-Forge)[ Packagist](https://packagist.org/packages/entity-forge/entity-forge)[ Docs](https://entityforge.dev)[ RSS](/packages/entity-forge-entity-forge/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (8)Versions (8)Used By (0)

Entity-Forge
============

[](#entity-forge)

A simple PHP Entity ORM for generating and managing entity models.

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

[](#installation)

Install via Composer:

```
composer require entity-forge/entity-forge
```

Features
--------

[](#features)

- Generating MySQL tables and related POCO classes from JSON objects.

Folder Structure
----------------

[](#folder-structure)

- `src/Core/` - Core classes like ModelGenerator
- `src/EntityConnector/` - Database connection classes
- `src/EntityGenerator/` - Model generation logic
- `src/EntityModels/` - Generated model classes

EntityForge
===========

[](#entityforge)

EntityForge is a lightweight PHP utility to generate PHP model classes and repository scaffolding from JSON model definitions. It focuses on developer productivity: define your data model as JSON, then generate POPO model classes and thin repositories that delegate data access to a central `EntityDriver`.

Version: 1.0

Goals
-----

[](#goals)

- Provide a simple, composable generator to convert JSON model descriptions into PHP model classes and repositories.
- Keep runtime footprint minimal — generated model classes are plain PHP objects; repositories are thin adapters.
- Make the code generation pipeline extensible (custom templates or additional generators).

Quick Install
-------------

[](#quick-install)

Install via Composer (local development):

```
composer install --dev
```

Project Layout
--------------

[](#project-layout)

- `src/Core/` — Generators: `ModelGenerator`, `RepositoryGenerator`.
- `src/EntityGenerator/` — Orchestration code that reads JSON models and invokes generators.
- `src/EntityModels/` — Generated model classes (POPOs).
- `src/EntityRepository/` — Generated repository classes (thin wrappers using `EntityDriver`).
- `src/JsonModels/` — JSON model definitions included with the package (used by the generator).
- `tests/` — PHPUnit tests that validate generation behavior.

JSON Model Format
-----------------

[](#json-model-format)

Each model is a JSON file with a top-level `model` (class name) and `fields` object. Example `src/JsonModels/users.model.json`:

```
{
  "model": "User",
  "fields": {
    "id": { "type": "int", "primary": true },
    "username": { "type": "string", "maxLength": 100 },
    "email": { "type": "string", "maxLength": 255 }
  }
}
```

The generator creates a PHP class `User` in `src/EntityModels/User.php` and a repository `UserRepository` in `src/EntityRepository/UserRepository.php`.

CLI: Generate Models &amp; Repositories
---------------------------------------

[](#cli-generate-models--repositories)

Use the bundled CLI to generate model and repository files from JSON models included in `src/JsonModels`:

```
php src/EntityGenerator/Entity:Gen create-model --model=users
```

- `--model` refers to the base filename in `src/JsonModels` (without `.model.json`).
- The command writes the generated model file to `src/EntityModels/` and repository to `src/EntityRepository/`.

Running Tests
-------------

[](#running-tests)

Install dev dependencies and run PHPUnit:

```
composer install --dev
vendor/bin/phpunit --testdox
```

Note: PHPUnit requires the PHP `dom` extension. On Debian/Ubuntu install via `sudo apt install php-xml`.

Future Work (planned for next releases)
---------------------------------------

[](#future-work-planned-for-next-releases)

- Read and write tables from the JSON model definitions directly (persist schema/state as JSON) instead of auto-creating SQL tables.
- Add configurable templates for code generation (allow custom class templates).
- Dependency injection for repositories and integration tests with an in-memory database.

Contribution
------------

[](#contribution)

Contributions welcome. Fork the repo, create a feature branch, and open a PR describing the change.

License
-------

[](#license)

MIT

###  Health Score

44

↑

FairBetter than 90% of packages

Maintenance93

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Total

6

Last Release

3d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18259805?v=4)[Vedavith Ravula](/maintainers/vedavith)[@vedavith](https://github.com/vedavith)

---

Top Contributors

[![vedavith](https://avatars.githubusercontent.com/u/18259805?v=4)](https://github.com/vedavith "vedavith (16 commits)")

---

Tags

phpframeworkormpdomigrationsentityrepositorysaascode-generationmulti-tenantmultitenancysymfony-consoledatabase-per-tenanttenant-isolation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/entity-forge-entity-forge/health.svg)

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

###  Alternatives

[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[typo3/cms-core

TYPO3 CMS Core

3713.2M5.1k](/packages/typo3-cms-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

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