简体   繁体   English

从现有表创建模型 (Symfony3)

[英]Create a model from existing table (Symfony3)

I have an existing table with 5 columns, and I want to generate an Entity without that generates a new migration with new table!我有一个包含 5 列的现有表,我想生成一个没有实体的实体,它会生成一个带有新表的新迁移!

Thanks!谢谢!

So, as I mentioned in comment - you just need to follow steps in Symfony documentation .所以,正如我在评论中提到的 - 你只需要按照Symfony 文档中的步骤进行操作。

This way, for Symfony 3 you need follow this:这样,对于 Symfony 3,您需要遵循以下步骤:

php bin/console doctrine:mapping:import --force AppBundle xml

This command line tool asks Doctrine to introspect the database and generate the XML metadata files under the src/AppBundle/Resources/config/doctrine folder of your bundle.这个命令行工具要求 Doctrine 内省数据库并在包的src/AppBundle/Resources/config/doctrine文件夹下生成 XML 元数据文件。

Once the metadata files are generated, you can ask Doctrine to build related entity classes by executing the following command.生成元数据文件后,您可以通过执行以下命令让 Doctrine 构建相关的实体类。

php bin/console doctrine:mapping:convert annotation ./src

It will generate Entity classes, and after that you must to remove the XML files, generated by first command.它将生成实体类,之后您必须删除由第一个命令生成的 XML 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM