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.