The Doctrine Project will be removing support for generating entities in Doctrine 3.
Not all development workflows will fit the proposed entity-first database management strategy.
To keep supporting a database-first workflow this project implements an alternative database oriented entity generator.
- Generate entities with type annotations, getters, setters, adders and removers;
- Supports
oneToMany
andmanyToOne
relationships, including pluralization of properties and methods.
This project is licensed MIT and can be used for free in any personal or commercial project.
bin/entity-generator entity-generator:generate
dsn
Accepts the same format as Doctrine, so the value configured in.env
can be usednamespace
Namespace for the generated entities (DefaultApp\Entity
)directory
Output directory for the generated entities (Defaultsrc/Entity
)collection-interface
Interface name for the collection type to use in the generated entities (Default\Doctrine\Common\Collections\Collection
)collection-implementation
(Default\Doctrine\Common\Collections\ArrayCollection
)
source .env
bin/entity-generator entity-generator:generate --dsn $DATABASE_URL
- A mapping is generated from an existing database using
SHOW CREATE TABLE
. - Entity classes are rendered using a Twig template.
- Only provides a
\PDO
based driver and an mapper forMySQL
-like sql dialects. - Annotations for (unique) indexes are not (yet) implemented
ManyToMany
relations are not (yet) supported (motivation)- Doctrine Custom types are not supported
- Naming conflicts on
xyx_id
with a foreign key and fieldxyx
(both becomexyz
) - Naming conflicts on multiple foreign keys from one table to another (
xyz.abc_1_id
andxyz.abc_2_id
both becomexyz.abcs
) - Blobs are not yet implemented