有没有在Symfony2应用程序中生成脚手架的功能? [英] is there a facility for generating scaffolding in a Symfony2 app?

查看:96
本文介绍了有没有在Symfony2应用程序中生成脚手架的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在Symfony 2中对脚手架进行搜索,并一直在寻找发电机"的参考,但是到目前为止,还没有能够使脚手架开始工作.

I've been doing searches on scaffolding in Symfony 2 and keep finding references to "generators" but so far have not been able to get scaffolding up and working.

通过脚手架",我指的是一种将工具指向数据库并让其生成视图/表单以执行CRUD操作的方法.

By "scaffolding" I'm referring to a way to point your tool at a database and have it generate views/forms to perform CRUD operations.

这对于快速制作原型和/或为某些数据库表构建粗略的管理工具很有用.

This can be useful for quickly prototyping something, and/or build a rough admin tool for some of your database tables.

它也可以为您正在构建的某种形式提供一个起点.

It can also provide a starting point for some form you are building.

在Symfony2中有可能吗?

Is this possible in Symfony2?

推荐答案

Crud操作由 SensioGeneratorBundle (包含在symfony标准发行版中).

Crud operations are provided by the SensioGeneratorBundle which is included in the symfony standard distribution.

您可以使用以下命令来生成表单,模板&现有实体的控制者.它是交互式的,还可以自动更新您的路由.

You can use the following command to generate form, templates & controller for existing entitites. It is interactive and can also update your routing automatically.

app/console generate:doctrine:crud

实体类本身可以用另一个命令-交互式创建.

entity classes themselfes can be created with another command - interactive aswell.

 app/console generate:doctrine:entity

从数据库生成实体的操作如下:

Generating entities from database is done with:

app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force

将创建xml映射文件.之后,您可以生成实体,如下所示:

which will create xml mapping files. Afterwards you can generate entities as follows:

app/console doctrine:mapping:import AcmeBlogBundle annotation
app/console doctrine:generate:entities AcmeBlogBundle

这将生成带有注释的实体.还支持yml和xml!

This would generate the entities with annotations. yml and xml are supported aswell!

这篇关于有没有在Symfony2应用程序中生成脚手架的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆