Laravel Blade views not showing the changes made to them
Asked Answered
E

7

7

System Details : Using WAMP2.5 in Windows 64 bit
MYSQL:5.6.17
PHP:5.5.12
Apache :2.4.9
I installed laravel via composer installation . It was all fine since recently all my views stopped showing any changes made to them . This is happening to views which use Blade template only.

I have created the blade files correctly and named them with filename.blade.php. My view File Structure -
views
        -layouts
                   defaults.blade.php
        show.blade.php
        login.blade.php
       

defaults.blade.php

<!DOCTYPE html>  
<html>
      <head></head>
<body>
  <div>
   <nav></nav>

       @yield('content')

  </div>
      @yield('footerscripts')

</body>
</html>

show.blade.php

@extends('layouts.defaults')
@section('content')
    --- SOME CONTENT ---
@stop

@section('footerscripts')
     --- js scripts ---
@stop

The same format was working perfectly but suddenly started acting strangely.Even after refreshing many times the view doesn't change,Once i tried deleting everything inside the view page still it showed up in the browser.
There are similar question but many didn't have accepted answer and the one with some ratings didn't worked for me . I also tried re-installing fresh new WAMP copy but no Help.It only works if i change its name but if i change it back to the original one it again starts showing the old version of it. Only happens with blade templating.

Erythropoiesis answered 2/7, 2014 at 19:4 Comment(2)
Updating the timezone in your config or in php.ini might cause Laravel to not realize that blade templates have changed. Any chance you did that? If so, @clarkf's solution of clearing /app/storage/views should work, though you should only have to do it once.Snook
I didn't changed the timeZone but does it checks the system's time and if the time of updation is greater, then it updates the view ? If it works like that then sure it will cause problem in my system cause my system always show wrong timing.Erythropoiesis
I
18

If you use PhpStorm:

  1. open menu File → Settings

  2. go to Deployment → Options section

  3. then uncheck Preserve files timestamps option

Incurious answered 1/3, 2017 at 14:56 Comment(0)
D
5

I'm not sure of the specifics, but this is related to how filemtime() is implemented in windows (possibly related bug here).

Illuminate\View\Compilers\BladeCompiler (well, it's parent class, Compiler) checks to see if a file has changed since last compilation by checking it's mtime, through Illuminate\Filesystem\Filesystem which calls calls filemtime() (see L179-188). Evidently this is failing to report properly on your system.

First, ensure that the app/storage/views directory has read, write and delete permissions. If this doesn't help, the simplest solution would be to clear the app/storage/views/ directory whenever making a change.

Demise answered 2/7, 2014 at 19:19 Comment(1)
If it just checks the System Time and updates the view only when if the time of updating was greater than the old one then I think probably its the problem of my System Time . It always shows wrong timing maybe CMOS battery problem .But this also happened in my friend's lappy(which has no Time problems) but it remained for a short duration ,after a while when he refreshed the view was updated.Erythropoiesis
N
1

I had this same issue , reason was I am doing uploads remote, but the time on my computer was different than what that was on my server

Nonunion answered 31/5, 2015 at 15:51 Comment(0)
S
1

I got very easy solution, I was having same project in two folders, I was editing one and php artisan was running on other, when get to that project where php server was running in it and made changes it worked.

Shipowner answered 14/2, 2021 at 1:59 Comment(0)
F
0
  1. In your cmd(command prompt) or terminal type and press enter... php artisan view:clear

For this to work, your terminal should be pointed to your root directory of your laravel installation/folder

  1. Or delete files in the folder storage/framework/views

In order to avoid the parsing of Blade files on each reload, Laravel is designed to caches views after Blade is parsed, to avoid re-parsing the blades on each reload.

  1. Or make sure you are editing the right view, in the right Laravel Installation.
Freely answered 11/2, 2017 at 21:36 Comment(0)
T
0

Run the command npm run production or npm run dev

It solved my problem: I had the same issue except my controller methods also did not want to reflect changes along with views. I tried the following commands:

user:/var/www/html/website$ php artisan cache:clear
Application cache cleared!
user:/var/www/html/website$ php artisan config:clear
Configuration cache cleared!
user:/var/www/html/website$ php artisan route:clear
Route cache cleared!
user:/var/www/html/website$ php artisan view:clear
Compiled views cleared!

Nothing changed.

I echoed an incorrect variable from a controller method. Nada!

I changed the app.css?v=2 file version. In the silence that followed after... there was no difference.

I cleared my browser cache.

I manually deleted: bootstrap/cache/config.php framework/sessions/* framework/views/*

No changes and finally I ran the command npm run production and bingo! Try it, it will save you 2 and a half hours of frustration and radical thoughts.

Laravel/framework v5.6

Tartuffery answered 20/7, 2020 at 20:51 Comment(0)
T
0

Clear cache and restart php-fpm. That solved it for me.

Tartary answered 6/5, 2022 at 14:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.