Symfony2命令行生成全局文件夹下的树枝模板
我使用的是 Symfony2.8,每当我使用命令行生成 控制器 和 twig 模板 时,模板都是在
I'm using Symfony2.8 and when ever I use the command line for generating controllers and twig templates the templates are created under
MyBundle/Resources/views/home/home.html.twig
我想遵循 symfony 文档建议的最佳做法 并将其放在
I want to follow the best practices suggested by symfony docs and have it inside of the
app/Resources/views/home/home.html.twig
我可以剪切并粘贴树枝文件,然后在必要时更改 {% extends %}
,但这样我头上的头发就会减少,因为我会把它拔出来.
I could just cut and paste the twig file and then change the {% extends %}
if necessary, but then I would have lesser hair on my head because I would be pulling it out.
那么我在提示中输入什么,以便它像往常一样在 MyBundle
中生成控制器,但树枝文件将位于全局 app/Resources/views
下文件夹
So what do I type in the prompt so that it generates the controller in the MyBundle
as usual BUT the twig files would be under the global app/Resources/views
folder
谢谢!
新的扩展问题
推荐答案
在玩了一下模板生成的路径后,我成功地将树枝文件放在了 app/Resources/views/文件夹中.
After playing a little with the path for template generation i succeeded in placing the twig file inside the app/Resources/views/ folder.
假设你有一个 symfony2 应用程序的标准架构:当生成器要求指定模板名称时,您可以为模板编写以下路径
Assuming that you have the standard architecture of a symfony2 app: You could write the following path for the template when generator asks to specify the Templatename
Templatename (optional) [AppBundle:Post:get.html.twig]: ::../../../../app/Resources/views/Post/get.html.twig
相关文章