gpt4 book ai didi

php - Silex v1.3 到 Silex v2 : Twig_Error_Runtime

转载 作者:可可西里 更新时间:2023-11-01 00:08:26 26 4
gpt4 key购买 nike

我最近将一切正常的 Silex v1.3 项目迁移到了 Silex v2。我收到一个 Twig 错误,我不明白原因

Twig_Error_Runtime in Template.php line 590:

Neither the property "request" nor one of the methods "request()", "getrequest()"/"isrequest()" or "__call()" exist and have public access in class "Silex\Application" in "index.twig" at line 5

这是我的 index.twig 文件的前 5 行

{% extends "layout.twig" %}


{% block stylsheets %}
<link rel="stylesheet" type="text/css" href="{{ app.request.basepath }}/public/libs/odometer/themes/odometer-theme-minimal.css" />

当然在布局中,我调用

{% block stylsheets %}{% endblock %}

但我完全不确定,问题出在 Twig 文件上......有什么需要改变的吗?

这是 Controller 的摘录:

$app->get('/', function () use ($app) {

return $app['twig']->render('index.twig', [
...
]);
})->bind('homepage');

感谢帮助

最佳答案

我发现 app.request.uri 不再适用于最近的 Twig。

但是如果你使用 global.request.uri 它工作正常。

我没有在 Twig 的文档中找到任何相关信息。

关于php - Silex v1.3 到 Silex v2 : Twig_Error_Runtime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38490126/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com