【发布时间】:2017-09-06 10:17:33
【问题描述】:
目前正在开发 Windows 10 上的 symfony 项目 2.8。 我想用 Twig 2.9.0 进行继承,如 symfony 的良好实践中所述:http://symfony.com/doc/current/templating/inheritance.html
我希望我的 DOCTYPE html 位于:src/myProject/CoreBundle/Resources/views/layout.html.twig
# {CoreBundle/Resources/views/layout.html.twig}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome !{% endblock %}</title>
{% block stylesheets %}{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
<link rel="stylesheet"
href="{{ asset('assets/vendor/bootstrap/dist/css/bootstrap.min.css') }}">
</head>
<body>
{% block body %}{% endblock %}
{% block javascripts %}{% endblock %}
</body>
</html>
然后我的 body 块将在 MyOwnBundle 中被覆盖:src/myProject/MyOwnBundle/Resources/views/layout.html.twig
# {MyOwnBundle/Resources/views/layout.html.twig}
{% extends 'CoreBundle::layout.html.twig' %}
{% block body %}
<div class="jumbotron">
<div class="container text-center">
<h1>Welcome to my Veterinary lab</h1>
<p></p>
</div>
</div>
{% block content %}
{% endblock %}
{% endblock %}
最后,我的内容块将在src/myProject/MyOwnBundle/Resources/views/MyApp/index.html.twig 中被覆盖。
这是我的问题:我可以通过我的虚拟主机http://veto.local/ 访问我的主页,但是当我修改布局中的任何内容(例如标题栏从“欢迎!”到“我的超级项目”)时,重新加载时没有任何反应网页。
我真的认为它来自缓存文件,但我做了三遍php app/console cache:clear,该过程以明确的声明结束,但仍然没有刷新!
你能帮我知道这是从哪里来的吗?
要配置我的虚拟主机,我遵循了 apache 文档:httpd//:apache.developpez.com/cours/virtual-host/
这是我的 vhost.conf,我在 httpd.conf (Include "C:\veterinary\veto_vhost.conf") 的末尾包含了这个文件:
<VirtualHost *:80>
ServerName veto.local
DocumentRoot C:\veterinary\veterinary\web
DirectoryIndex app.php
ErrorLog C:\veterinary\veterinary\veto-error.log
CustomLog C:\veterinary\veterinary\veto-access.log combined
<Directory "C:\veterinary\veterinary\web">
AllowOverride All
Allow from All
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Require local
Require all granted
</Directory>
</VirtualHost>
谢谢,
最好的问候,
【问题讨论】:
-
为了确保这确实是一个树枝缓存问题,您可以进入文件夹
/var/cache/ENV/twig(将ENV替换为您正在使用的环境)并删除那里的所有文件。cache:clear命令也应该这样做。如果可以,我建议您在本地开发(通过在项目根目录中运行php bin/console server:run,这将启用开发模式,正确启动服务器中的 php 构建,并在您更改后处理正确的缓存项目文件)
标签: php html apache symfony twig