Doctrine248 command line tool generation Yml/xml/entities

Source: Internet
Author: User
the Tools directory of the Doctrine2 compressed package is used to do some command-line work. The main point here is that through tools, the table structure of the database is automatically generated yml/xml/entities, because writing those things is too waste time to have wood.

1. Through the doctrine orm:convert-mapping command Generation XML/YML

usage:orm:convert-mapping [Options] [--]
  
  
   
  Orm:convert:mappingarguments:to-type the mapping type to be converted. Dest-path the path to generate your entities classes. Options:--filter=filter A string pattern used to match entities this should be processed.      (Multiple values allowed)--force force to overwrite existing mapping files.      --from-database Whether or not to convert mapping information from existing database.      --extend[=extend] defines a base class to being extended by generated entity classes.  --num-spaces[=num-spaces] Defines the number of indentation spaces [Default:4]--namespace[=namespace] defines a  Namespace for the generated entity classes, if converted from database. -H,--help Display This help message-q,--quiet does not output any message-v,-- Version Display This application version--ansi forceANSI output--no-ansi Disable ANSI Output-n,--no-interaction do don't ask any interactive QUESTION-V|VV|VVV,--verbose increase the verbosity of messages:1 for normal output, 2 for more verbose OUTP  UT and 3 for Debughelp:convert mapping information between supported formats. This was an execute one-time command.  It should not being necessary for the multiple times and especially when using the--from-database flag. Converting an existing database schema into mapping files is solves about 70-80% of the necessary mapping information. Additionally the detection from a existing database cannot detect inverse associations, inheritance types, entities with  Foreign keys as primary keys and many of the semantical operations on associations such as Cascade. Hint:there is no need to convert YAML or XML mapping files to annotations every time you make changes. All mapping drivers is first class citizens in Doctrine 2 and can be USed as runtime mapping for the ORM.  Hint:if you has a database with tables this should not being managed by the ORM, you can use a Dbal functionality to filter The tables and sequences down to a global level: $config->setfilterschemaassetsexpression ($REGEXP);
  
 

Above is help, an example below

/var/www/doctrine$ php vendor/bin/doctrine orm:convert-mapping XML config/xml/--from-database

Here are the commands executed on Linux, first CD to /var/www/doctrine below (some rookie asked, CD is what east, for Mao is this directory ~~cd is what, goodbye, this problem Baidu go. Why this is the directory, this is the project folder, in short, there is a doctrine package below). The preceding command omits the explanation, explaining that the following "XML" means the resulting file type, "config/xml/" is the XML storage directory,--from-database means to generate from the database.

2. Generate YML, then generate entities.

/var/www/doctrine$ php vendor/bin/doctrine orm:generate-entities src/--regenerate-entities

this simple, my entities put in /var/www/doctrine/ SRC below, purely for testing, the post-architecture will change

To Mr. YML again generate entities, can not directly generate entities, anyway I did not succeed, possible operation problems?

PHP orm This article is too few, because this is not commonly used, plainly speaking php orm eggs with little, purely convenient

The above describes the Doctrine248 command line tool generation Yml/xml/entities, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.