Symfony2命令行生成全局文件夹下的twig模板 [英] Symfony2 commandline generation of twig templates under global folder
问题描述
我使用的是 Symfony2.8,当我使用命令行生成控制器和树枝模板时,模板是在
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 docs 建议的最佳实践
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
谢谢!
推荐答案
在对模板生成路径稍加调整后,我成功地将 twig 文件放置在 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
这篇关于Symfony2命令行生成全局文件夹下的twig模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!