自动为 Zend Framework 等控制器操作渲染 Symfony2 模板
我来自 Zend Framework 背景,创建页面的过程是:
- 创建一个控制器
- 创建一个空操作
- 为控制器创建一个文件夹 创建
- 一个与控制器操作名称匹配的文件并将其放在控制器的目录中
当您通过 http://host/controller/action 访问应用程序时,视图文件会自动呈现。
我是否可以在 Symfony2 中执行此操作,这样我就不必为每个控制器/操作创建路由条目?并自动渲染每个动作的树枝模板?
提前致谢
I am coming from a Zend Framework background, and the process for creating a page is:
- Create a controller
- Create an empty action
- Create a folder for the controller
- Create a file matching the name of the controller action and place it in the directory for the controller
When you access the application via http://host/controller/action the view file is automatically rendered.
Is it possible for me to do this within Symfony2 so that I do not have to create routing entries for each controller/action? and automatically render the twig templates for each action?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 SensioFrameworkExtraBundle。
模板是
Resources/views/My/my.twig.html
。请注意,您必须在操作方法中返回一些内容。You can use the
@Template
annotation from the SensioFrameworkExtraBundle.The template is
Resources/views/My/my.twig.html
. Note that you have to return something in the action method.