Doctrine ORM

Doctrine2 ORM – Doctrine Console Commands


Convert mapping information between supported formats

Reverse Engineering

Reverse engineer a database using the orm:convert-mapping command.

Convert database to doctrine mapping

$ php ./www/index.php orm:convert-mapping --from-database xml <path>/xml
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="" xmlns:xsi="" xsi:schemaLocation="">
 <entity name="Article" table="article">
 <id name="id" type="integer" column="id">
 <generator strategy="IDENTITY"/>
 <field name="title" type="string" column="title" length="255" nullable="false"/>
$ php ./www/index.php orm:convert-mapping --from-database php <path>/php

use DoctrineORMMappingClassMetadataInfo;

 'name' => 'address',
 'fieldName' => 'id',
 'columnName' => 'id',
 'type' => 'integer',
 'nullable' => false,
 'unsigned' => false,
 'id' => true,
 'fieldName' => 'name',
 'columnName' => 'name',
 'type' => 'string',
 'nullable' => false,
 'length' => 255,
 'fixed' => false,

Reverse Engineering is not always working perfectly depending on special cases. It will only detect Many-To-One relations (even if they are One-To-One) and will try to create entities from Many-To-Many tables.

It also has problems with naming of foreign keys that have multiple column names.

Any Reverse Engineered Database-Schema needs considerable manual work to become a useful domain model.


Jedna myšlenka na “Doctrine2 ORM – Doctrine Console Commands”

Napsat komentář

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *