sprimault / ormeau-doctrine
Generates Doctrine entities from a legacy database and regenerates them without overwriting your code
Package info
github.com/sprimault/ormeau-doctrine
Type:symfony-bundle
pkg:composer/sprimault/ormeau-doctrine
Requires
- php: >=8.1
- doctrine/orm: ^2.14 || ^3.0
- nikic/php-parser: ^5.0
- symfony/console: ^5.4 || ^6.4 || ^7.0 || ^8.0
- symfony/framework-bundle: ^5.4 || ^6.4 || ^7.0 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.5 || ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
ormeau-doctrine
The Symfony bundle of Ormeau: it generates Doctrine entities from a legacy database, and regenerates them six months later without discarding the code written on them since.
Doctrine removed doctrine:mapping:import, and nothing official replaced it.
Ormeau takes over a real legacy database β T_ prefixes, foreign keys never
declared, booleans stored as char(1) β and produces associations where a
literal translation would leave integer columns.
Important
This repository is a read-only mirror of the php/ directory of
sprimault/ormeau, rewritten on every
merge. Issues, pull requests and documentation live in the main repository.
What it needs
The bundle does not read the database. It reads a logical layer produced by the
ormeau binary, a single file to download from the
releases, with nothing
else to install. PostgreSQL or SQL Server, for instance:
$ ormeau extraire --dsn "postgres://app:secret@srv:5432/gescom" --sortie gescom.calque.json $ ormeau inferer gescom.calque.json
ormeau inferer writes gescom.logique.json, and a decisions file where you
settle what the tool cannot decide on its own.
Installation
$ composer require --dev sprimault/ormeau-doctrine $ bin/console ormeau:generer gescom.logique.json
One database per entities directory: files name their database, and another
database does not overwrite them without --remplacer=<base>. Only what
prevents the requested generation returns 1: a file from another database, or
an unreadable PHP file under the entities directory. Skipped entities and
diverging classes return 0.
The whole workflow β extracting the layer, inferring, arbitrating, generating β is described in the main README, and what each version changes in the changelog.
Verification
The bundle's tests run under five combinations of PHP, Symfony, Doctrine ORM
and DBAL, from PHP 8.1 with Symfony 5.4 and ORM 2.14 to PHP 8.4 with Symfony 8
and ORM 3, and the entities generated for every reference case pass the mapping
validator of the installed ORM. On the binary side, integration tests run
against a real database server, never a simulated catalog, and the extraction
of the test database is compared byte for byte with a reference layer. The
whole chain β extraction, generation, schema:create in an empty database β is
replayed under ORM 3 and ORM 2.14, and the recreated database compared with the
original: each remaining difference is listed with its reason.
CI only confirms: every change first goes through the same full validation, on Windows and Linux machines, before it is pushed.
Where the name comes from
Ormeau β pronounced roughly or-MOH β is French for a young elm, and for the abalone, a shellfish whose shell is built from stacked layers of nacre. It also happens to begin with ORM, which is convenient for a tool that produces ORM entities.
The pivot format is called a calque, in the tracing-paper sense: a faithful copy of the catalogue, with no interpretation. In linguistics a calque is a structural borrowing from one language into another β English skyscraper becoming French gratte-ciel. That is precisely the operation: carrying the structure of a relational schema over into another language's type system.
License
Apache 2.0 β see LICENSE. The entities Ormeau generates are yours:
the licence covers the tool, not its output.