我开始学习 Symfony,但我对放置此页面上显示的示例 YAML 代码的确切位置感到困惑:https://symfony.com/doc/current/cookbook/templating/render_without_controller.html
具体来说,此代码位于何处:
acme_privacy:
path: /privacy
defaults:
_controller: FrameworkBundle:Template:template
template: static/privacy.html.twig
在寻找答案时我能找到的最接近的东西是这篇文章:Not using templates Symfony 2 。但是,它也没有说明将此代码放置在哪里。
谢谢
编辑:我的 app/config/routing.yml 文件
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error
_main:
resource: routing.yml
我将其添加到文件末尾并且它起作用了!
testing_privacy:
path: /privacy
defaults:
_controller: FrameworkBundle:Template:template
template: static/privacy.html.twig
最佳答案
可能在app/config/routing.yml
关于php - 如何在没有 Controller 的情况下渲染静态页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33151838/