So I began working on Symfony2 framework, i had to map an existing database with Doctrine2. First of all, keep in mind that Doctrine2 gives its best for creating a schema, not for generating an object model from an existing one.
It's therefore important to "prepare" your database before generation unless you'll get an approximative model...
- You must define a Primary Key on each table of your DB. It seems obvious but Doctrine2 will fail otherwise...
- Composite primary keys including only foreign keys is not yet fully supported by Doctrine2 (see documentation). Think about adding an auto-increment integer as PK and apply a UNIQUE index on foreign keys from old composite PK.
- Natively, Doctrine2 doesn't natively resolve BIT, BINARY, VARBINARY, TINYBLOB, MEDIUMBLOB, BLOB, LONGBLOB, ENUM, SET, GEOMETRY, POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON and MULTIPOLYGON.
- Important : Doctrine2 converts SQL type TINYINT to PHP type boolean. Use at least a SMALLINT if you want to mean an integer.
- Doctrine automatically assignes IDs with generator (PHP equivalent to auto_increment) but it does it for all types of simple Primary Keys, even strings and foreign keys...
When you're satisfied of your schema, you can generate the metadatas with the command CLI interface :