Giter Site home page Giter Site logo

doctrine2-exporter's Introduction

Build Status Latest Stable Version Total Downloads License

README

This is an exporter to convert MySQL Workbench Models (*.mwb) to a Doctrine 2 Schema.

Prerequisites

  • PHP 7.2+
  • Composer to install the dependencies

Installation

composer require --dev mysql-workbench-schema-exporter/doctrine2-exporter

This will install the exporter and also require mysql-workbench-schema-exporter.

You then can invoke the CLI script using vendor/bin/mysql-workbench-schema-export.

Configuration

Model Comment Behavior

  • {d:bundleNamespace}AcmeBundle{/d:bundleNamespace} (applied to Table)

    Override bundleNamespace option.

  • {d:m2m}false{/d:m2m} (applied to Table)

    MySQL Workbench Schema Exporter tries to automatically guess which tables are many-to-many mapping tables and will not generate entity classes for these tables.

    A table is considered a mapping table, if it contains exactly two foreign keys to different tables and those tables are not many-to-many mapping tables.

    Sometimes this guessing is incorrect for you. But you can add a hint in the comment of the table, to show that it is no mapping table. Just use {d:m2m}false{/d:m2m} anywhere in the comment of the table.

  • {d:unidirectional}true{/d:unidirectional} (applied to ForeignKey)

    All foreign keys will result in a bidirectional relation by default. If you only want a unidirectional relation, add a flag to the comment of the foreign key.

  • {d:owningSide}true{/d:owningSide} (applied to ForeignKey)

    In a bi-directional many-to-many mapping table the owning side of the relation is randomly selected. If you add this hint to one foreign key of the m2m-table, you can define the owning side for Doctrine.

  • {d:cascade}persist, merge, remove, detach, all{/d:cascade} (applied to ForeignKey)

    You can specify Doctrine cascade options as a comment on a foreign key. They will be generated into the Annotation. (Reference)

  • {d:fetch}EAGER{/d:fetch} (applied to ForeignKey)

    You can specify the fetch type for relations in the comment of a foreign key. (EAGER or LAZY, doctrine default is LAZY)

  • {d:orphanRemoval}true{/d:orphanRemoval} (applied to ForeignKey)

    Another option you can set in the comments of foreign key. (Reference)

  • {d:order}column{/d:order} (applied to ForeignKey)

    Apply OrderBy annotation to One To Many and Many To Many relation. OrderBy annotation can be written in the following format:

    column[,(asc|desc)]
    

    Multiple columns are supported, separated by line break. Example usage:

    {d:order}
      column1
      column1,desc
    {/d:order}
    
  • {d:cache}READ_ONLY, NONSTRICT_READ_WRITE, READ_WRITE{/d:cache} (applied to Table and/or ForeignKey)

    You can specify Doctrine second level caching strategy as a comment on a table or foreign key. They will be generated into the Annotation or YAML. (Reference)

  • {d:relatedNames}RelationTable:NewName{/d:relatedNames} (applied to Table)

    Overrides relatedVarNameFormat.

    Rename generated related column names when the table names and the relatedVarNameFormat pattern are not good enough. The format should be CamelCase singular and should map with the class name that is generated for the related entity. Can be written in the following format:

    RelationTableName:CustomRelationName
    

    Multiple relations are supported, separated by line break. Example usage: - on a "store_products" table with "store_product_categories" and "store_product_images" related tables:

    {d:relatedNames}
    StoreProductCategory:Category
    StoreProductImage:Image
    {/d:relatedNames}
    

    It can be used in both parent / child tables. For example, on a "store_product_images" table:

    {d:relatedNames}
    StoreProduct:Product
    {/d:relatedNames}
    

    The generated StoreProduct class will have "category" and "image" properties instead of "storeProductCategory" and "storeProductImage", while the "StoreProductImage" class will have a "product" property instead of "storeProduct".

Command Line Interface (CLI)

See documentation for mysql-workbench-schema-exporter

Links

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.