【问题标题】:render php file return template ::/var/www/vhosts/ does not exist渲染 php 文件返回模板 ::/var/www/vhosts/ 不存在
【发布时间】:2020-02-26 14:33:12
【问题描述】:

我在我的项目中使用 Plesk。当我渲染一个树枝文件时它工作正常,但是当我在我的控制器中渲染一个 php 文件时发生错误:

 "The template "::/var/www/vhosts/domain/httpdocs/project/templates/test.php" does not exist."

这是我的代码:

$this->render('/var/www/vhosts/domain/httpdocs/project/templates/test.php');

【问题讨论】:

  • 请检查您是否在渲染函数中提供了正确的文件路径

标签: php file templates render plesk


【解决方案1】:
$this->render('/var/www/vhosts/domain/httpdocs/project/templates/test.php');

上面的代码在symfony中是错误的。渲染函数(在控制器中使用)用于渲染树枝文件内容。上面的代码给出了这样的结果

No engine is able to work with the template "/var/www/vhosts/domain/httpdocs/project/templates/test.php"

【讨论】:

  • PHP 模板在 Symfony 4.3 中已被弃用,它们将在 Symfony 5.0 中不再受支持。改用 Twig 模板。(symfony.com/doc/current/templating/PHP.html)
  • 我在另一台服务器 (linux) 上使用了相同的代码,它工作正常,但在 Plesk 服务器上,它不起作用。
【解决方案2】:

我在 framework.yaml 模板中添加了:engines: ['twig', 'php'] 这样我就可以重新编写文档中提到的 php 文件 https://symfony.com/doc/current/templating/PHP.html

【讨论】:

    猜你喜欢
    • 2013-10-25
    • 1970-01-01
    • 2015-06-23
    • 1970-01-01
    • 2016-06-07
    • 2013-07-11
    • 2014-03-10
    • 2023-01-01
    • 2018-01-17
    相关资源
    最近更新 更多