This question already has an answer here:
Reference a static template in symfony2
(1个答案)
三年前关闭。
我目前正在将一个遗留系统导入Symfony,我有几个页面有静态HTML页面,这些页面不使用Twig,我只想创建直接到这些页面的路由,绕过任何控制器等。
/aboutus maps to /web-directotry/aboutus.html

这可能就在路由部分吗?

最佳答案

当然可以。
在您的routing.yml中:

about_us:
    path: /aboutus
    defaults:
        _controller: FrameworkBundle:Template:template
        template: "/absolute/path/to/aboutus.html"

例如,/absolute/path/to/test.html可以是/var/www/PROJECT/web/aboutus.html
如果您可以遵循视图的“默认”结构(从任何捆绑包中),则可以将它们添加到项目的app/Resources/views/目录中。
然后您可以直接使用template: "aboutus.html",它将在/PROJECT/app/Resources/views/aboutus.html自动检索。
您可以在Render without controller中找到所有相关信息。
希望你对Symfony有很好的经验。

关于php - 使用Symfony路由到免费的Twig HTML页面,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36941266/

10-12 12:43
查看更多