Blade view not reflecting changes
Asked Answered
F

13

60

I am developing a Laravel(5.2.29) project in Windows environment and testing it on Chrome browser.

I have made some changes on a Blade file using atom text editor and then refreshed my page and noticed that suddenly it has stopped reflecting the changes (it's loading the old Blade file).

I've tried the following:

  • Restarted the browser
  • Clearing browser cache
  • Running php artisan cache:clear
  • Running composer dumpautoload
  • Deleting the Blade file (and got a view not found error). Then created a new Blade file with the same name, with no content and refreshed the page.

No matter what, the code displayed on the browser is always the same (old) version and not the content of the Blade file.

How can I solve this issue?

Fougere answered 28/5, 2016 at 20:50 Comment(0)
A
73

In order to avoid the parsing of Blade files on each reload, Laravel caches the views after Blade is processed. I've experienced some situations where the source (view file) is updated but the cache file is not "reloaded". In these cases, all you need to do is to delete the cached views and reload the page.

The cached view files are stored in storage/framework/views.

Arlynearlynne answered 28/5, 2016 at 21:5 Comment(14)
this worked..i have deleted all the views under framework. thanks.Fougere
I tried the same but I still see old view's cached version.Clotilda
Cache is actually empty for meIseult
I have a similar situation, but it not only affects the views but the controllers as well. I believe the issue is related to the difference in time between the testing server and my laptop. Unfortunately I haven't been able to resolve it no matter what I do :(Castrate
Just as an update, I was able to resolve this issue by pointing both my development environment and the testing server to the same time server so both have the exact same time. Hope this helpsCastrate
@Castrate How did you point your development environment to the same time server?Boastful
If you do this you'll have problems in your app. Use php artisan view:clear insteadTuyere
@ConnorLeech can you expand on that? What issues have you experienced with this? ThanksBorrowing
I was getting an error that the path to this directory not found and Laravel error screen. I recreated the directory manually but think using built in artisan commands to handle this is best practice. Related issue: github.com/laravel/framework/issues/7295Tuyere
You would think that php artisan view:clear would exactly do this for you, but it did not work for me, whereas manually deleting the cached view files from the storage/framework/views folder worked.Teeny
Php artisan cache:clear didn't work but manually deleting the framework/views folder worked for meDemmy
I realized finally. There was a similar xml . In other viwes folder. Have checked the path out and it plays ok againDharna
@danboh, your answer resolved my issue. My Computers time somehow got behind and affected my code changes from reflecting.Idiom
This worked for me, I deleted the old folder and then created the new empty one.Choreograph
W
58

Run this command from terminal

php artisan view:clear
Wimple answered 1/2, 2017 at 11:57 Comment(3)
It is there in 5.2 as per op requirement. Run php artisan and check yourself before downvoting this answer.Wimple
This actually worked for me. This is just to confirm, the command do exist and it got rid of the cached view I was getting.Latterll
Yes, this fixed it for meFlowerage
S
18
php artisan cache:clear
php artisan route:cache
php artisan config:clear
php artisan view:clear
rm -rf bootstrap/cache/*/*
  • Delete Cache/OPcache from PHP (fpm) of your Nginx/Apache server.
Sforza answered 31/10, 2019 at 13:36 Comment(1)
...one (or all) of these worked. I was too lazy to run them one by one and check if it worked after eachTrotskyism
O
17

If you use PhpStorm, uncheck Preserve files timestamps deployment option: https://mcmap.net/q/330182/-laravel-blade-views-not-showing-the-changes-made-to-them

Odoric answered 1/3, 2017 at 14:59 Comment(1)
This is it for me - the problem only started when I started to use PHPStorm midway through a project so I knew it wasn't anything with laravel!Olli
T
6

Clear the cache and clear the cached blade files:

php artisan cache:clear
php artisan config:clear
php artisan view:clear
Tuyere answered 24/2, 2018 at 23:13 Comment(0)
L
5

You can also check if opcache enabled, in that case you need to clear your opcache cache.

Laissezfaire answered 18/9, 2018 at 21:22 Comment(1)
This was it for me. service php7.0-fpm reload resolved the issue.Korn
P
5

Like Can Gelis mentionned in a comment. For me the solution was to reload PHP FPM

service php7.2-fpm reload

Parasite answered 5/12, 2019 at 18:17 Comment(1)
You saved my sanity. I've been working on this for a few hours now. Thanks!Buenabuenaventura
M
3

Alternatively if other suggested methods did not work, you can rename your files to different names. Refresh their corresponding web pages to start using new file name reference. Then you can rename the files back to your preferred names after the new pages to reflect their changes.

Myrnamyrobalan answered 1/8, 2018 at 9:23 Comment(1)
@Michel please explain more. It does work as long as you will change file name to new name and back to the original name after refreshing your page.Myrnamyrobalan
T
1

I tried everything, cache clear commands and deleting the storage framework view folder but nothing worked. Finally, this command worked for me perfectly.

php artisan optimize
Touristy answered 25/4, 2023 at 19:10 Comment(1)
If you read what optimize does, this will create a cache of the framework bootstrap files, which is probably not desirable for cache busting. In any case, this did not work for me and neither did running php artisan optimize:clear beforehand.Greylag
D
0

I have cleared all cashs and uploaded folders but didnt see changes. Thus, if you have placed the project on a public hosting and don't have access to console then try to set deployment via your IDE (mine is phpstorm, e.g.)and set it to autoload mode. Then you'll get it working by changing something in the problem blade and by pressing cntrl+s(save) shortcut.

Dharna answered 29/6, 2020 at 13:35 Comment(0)
D
0

clear cache didn't work for me, but I just edited the file and saved it again, and it works!

Dielu answered 14/11, 2020 at 2:34 Comment(0)
C
0

None of these solutions have resolved this issue for me. Tried all php artisan options and the php code is not updating.

Only solution i've found is restarting the docker container that the code is running inside.

Creator answered 15/6, 2021 at 17:7 Comment(0)
H
-1

In case you try everything and nothing works. I recommend that you simply create a view under another name and the problem will be fixed

Example:

welcome.blade.php 

change to

newview.blade.php

copy and paste code to new view

In controller just point to new view:

return view('newview');
Hughey answered 7/12, 2021 at 7:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.