【问题标题】:Unable to load the "Symfony\Bridge\Twig\Form\TwigRenderer" runtime无法加载“Symfony\Bridge\Twig\Form\TwigRenderer”运行时
【发布时间】:2017-11-30 19:56:16
【问题描述】:

我一直在努力将现有的 Symfony3 Web 应用从本地 LAMP 主机迁移到 Goggle 的 App Engine 标准 PHP 环境。我从appengine-symfony-starter-project 获得了使用 Memcache 进行会话、预缓存应用程序代码并连接到 Cloud SQL MySQL 数据库的提示。让核心部件正常工作。

我使用 TWIG 模板在 /login 添加了一个登录表单,其中的表单如下所示:

<form class="form" action="{{ path('security_login') }}" method="post">
  <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
  <div class="form-group">
    <input class="form-control" id="email" type="text" name="_email" placeholder="Email" value="{{ last_username }}"/>
  </div>
  <div class="form-group">
    <input class="form-control" id="password" type="password" name="_password" placeholder="Password"/>
  </div>
  <div class="form-group">
    <input type="checkbox" id="remember_me" name="_remember_me" checked>
    <label for "remember_me">Remember Me</label>
  </div>
  <div class="form-group">
    <button class="btn btn-round btn-b">Login</button>
  </div>
  <div class="form-group"><a href="{{ path('security_reset') }}">Forgot Password?</a></div>
</form>

这在本地 DEV 和 TEST 环境中运行良好,但是当我将其推送到 GAE 时,我收到以下错误:

Unable to load the "Symfony\Bridge\Twig\Form\TwigRenderer" runtime.

我已经挖掘了几个小时,但没有发现这里出了什么问题。有谁知道去哪里看?

提前致谢,

【问题讨论】:

  • 我无法复制该错误,但您是否在 app/config.yml 中启用了framework.templating.engines: ['twig']?您的 composer.lock 文件是否列出了 twig/twig?另外,清除缓存。
  • 其他使用 Twig 模板的页面运行良好,我认为这不是问题。与我之前链接的启动项目一起,采取了一些额外的步骤,以便缓存预热工作,一旦部署,我们不必对文件系统进行任何写入,因为这是不允许的。我担心可能需要更多的热身。

标签: php symfony google-app-engine


【解决方案1】:

在我的情况下,“twig.strict_variables:true”到“twig.strict_variables:false”修复了一个问题。

【讨论】:

  • 似乎对我没有影响。不过感谢您的建议。
  • 您可以在生产配置中尝试“twig.strict_variables: false”吗?
  • 我有。还修改了 AppBundle\TwigTwig\Environment::getOptionsHash() 以将其删除。这两种方法都不能解决我的问题。
  • 我已对 composer 进行了更新,该问题已自行修复。认为有一些热修复。你能试试吗?真的很好奇
【解决方案2】:

我们今天早上在工作中遇到了同样的错误,在 Silex 应用程序中。

这对我们有帮助:https://github.com/silexphp/Silex/pull/1571

我们可以在 composer.json 中将 symfony/form 的版本从 ~2.8|^3.0 更改为 ~2.8|3.3,因为 TwigRenderer 在 3.4 中似乎已被弃用。

希望这会有所帮助。

【讨论】:

  • 一直在摆弄,已经升级到 SF 3.4.1。我现在遇到了同样的错误,只是它抱怨无法加载 Symfony\Component\Form\FormRenderer 而不是 TwigRenderer。
猜你喜欢
  • 1970-01-01
  • 2018-11-06
  • 1970-01-01
  • 2019-01-14
  • 1970-01-01
  • 2018-12-19
  • 2021-12-25
  • 2016-04-21
  • 1970-01-01
相关资源
最近更新 更多