简体   繁体   中英

Symfony twig does not refresh my pages

Currently working on a symfony project 2.8 on Windows 10. I want to make inheritance with Twig 2.9.0 as explained in the good practices with symfony: http://symfony.com/doc/current/templating/inheritance.html

I want my DOCTYPE html to be located in : 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>

Then my body block will be overriden in 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 %}

Finally, my content block will be overriden in src/myProject/MyOwnBundle/Resources/views/MyApp/index.html.twig .

Here is my problem: I can access my homepage through my vhost at http://veto.local/ but when I modify anything in my layouts (for example the title block from "Welcome !" to "My Super Project") nothing happen while reloading the web page.

I truly think that its coming from the cache files but I did php app/console cache:clear three times, the process finishes as a clear statement but still, nothing is refreshed !

May you help me to know where does that comes from ?

To configure my vhost I followed the apache documentation: httpd//:apache.developpez.com/cours/virtual-host/

Here is my vhost.conf and I included this file at the end of my 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>

Thank you,

Best regards,

It looks like you're using production environment ( app.php entrypoint) while developing you app..

Try http://veto.local/app_dev.php to use development environment, or if you really want to use production env use

php app/console cache:clear --env=prod

because by default this command clear dev cache.

php app/console cache:clear

clears the cache for the dev environment. You can reach that by calling http://veto.local/app_dev.php . In this environment, changes to any files are automatically detected and there is no real need for clearing the cache. As the name suggests, this is the preferred environment during development.

http://veto.local/ however is known as the prod environment. Here changes to files are not automatically detected and you have to clear the cache manually to see the effects. You can do this by calling

php app/console cache:clear --env=prod

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM