Skip to Content

Using ORM Designer with Symfony 2.

Steven Lewis, Internal Projects Web Developer

The author

Steven Lewis

Internal Projects Web Developer

We’ve just started using the Symfony 2 framework along with its Doctrine 2 ORM extensions to write some of our new web tools. I was able to get a free trial of ORM designer, a visual tool to aid in design of the data model. I have not been disappointed with my experience so far.

We’ve just started using the Symfony 2 framework along with its Doctrine 2 ORM extensions to write some of our new web tools. I was able to get a free trial of ORM designer, a visual tool to aid in design of the data model. I have not been disappointed with my experience so far. I found Doctrine 2 to be an excellent ORM with great documentation. It takes much of the pain out of hooking up PHP objects to the database and persisting the data. From a mapping definition file (written in YAML in my case), Doctrine2 provides tools to generate both the PHP Entities (Models) and to actually create and apply a database schema. Effectively, once the mapping file has been written, it is a matter of executing two commands and then the developer is able to write code using Doctrine models. The mapping file itself is something that is not particularly intuitive, and could be quite tedious to write, but essentially, it defines field/property definitions, formatting and the relationships between entities. Each Entity has a single mapping file.

Editing a model using ORM Designer

ORM Designer allows a developer to create a UML diagram. Properties and relationships, default values, and validation can all be defined with its simple GUI interface. The model can then be saved away, and possibly built upon later as the project grows. I was able to configure ORM Designer to export the model, as YAML mapping files, directly into my Doctrine2 mappings directory with the click of a mouse button. Following this operation, it was just a case of running the two commands to automatically update the database schema and the Doctrine Entities. Not only is this tool useful for turbo-charging the creation of Doctrine2 Entities, but it provides a visual representation of your data model that is likely to be useful while conceptualizing your project before any code has been written. It can be used as an aid for communicating the workings of your system to other members of the team or a client, but most importantly, it can be used as a definitive reference and point of update for the data model of the project on which the code depends. ORM Designer also allows export of its models to Doctrine, Propel and CakePHP although I’ve not tried these. In summary, I’m impressed! ORM Designer is not overly complex but it does what it needs to do very well. If you have tried ORM Designer, or have another recommendation - let me know your thoughts by leaving a comment below.