최근 Silex v2에 모든 것이 잘 작동되는 Silex v1.3 프로젝트를 마이그레이션했습니다. 나는 원인Silex v1.3에서 Silex v2로 : Twig_Error_Runtime
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 %}
하지만 확실하지 않습니다. 문제는 나뭇 가지 파일에 있습니다 ... 뭔가 변경해야합니까? 도움
나를 위해 트릭을했기 때문에 그냥 상향 조정했는데, 왜 내가 선택한 대답이 나에게 효과가 없었는지 모르겠다. 호기심에서 어떻게 찾았습니까? – mikelovelyuk
두 답변 모두 나를 위해 일하지만, app.request를 global.request로 변경하는 것이 더 쉽다는 것에 동의합니다. – Macbernie
@mikelovelyuk 코드를 읽음으로써 알게되었습니다. (한 달 전에 이것을 발견했습니다 : http : //silex.sensiolabs. org/doc/providers/twig.html # global-variable – seblucas