laravel 刀片视图不反映变化
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37503627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Blade view not reflecting changes
提问by Noob Coder
I am developing a Laravel(5.2.29) project in Windows environment and testing it on Chrome browser.
我正在 Windows 环境中开发 Laravel(5.2.29) 项目并在 Chrome 浏览器上对其进行测试。
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).
我使用 atom 文本编辑器对 Blade 文件进行了一些更改,然后刷新了我的页面,并注意到它突然停止反映更改(它正在加载旧的 Blade 文件)。
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 founderror). Then created a new Blade file with the same name, with no content and refreshed the page.
- 重新启动浏览器
- 清除浏览器缓存
- 跑步
php artisan cache:clear
- 跑步
composer dumpautoload
- 删除 Blade 文件(并出现未找到视图错误)。然后创建了一个同名的新 Blade 文件,没有内容并刷新了页面。
No matter what, the code displayed on the browser is always the same (old) version and not the content of the Blade file.
无论如何,浏览器上显示的代码始终是相同(旧)版本,而不是 Blade 文件的内容。
How can I solve this issue?
我该如何解决这个问题?
回答by Luís Cruz
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.
为了避免每次重新加载时解析 Blade 文件,Laravel 会缓存 Blade 处理后的视图。我遇到过一些源(视图文件)更新但缓存文件没有“重新加载”的情况。在这些情况下,您需要做的就是删除缓存的视图并重新加载页面。
The cached view files are stored in storage/framework/views
.
缓存的视图文件存储在storage/framework/views
.
回答by Bugfixer
Run this command from terminal
从终端运行此命令
php artisan view:clear
回答by Arthur Shlain
If you use PHPStorm, uncheck Preserve files timestamps
deployment option:
https://stackoverflow.com/a/42534996/2453148
如果您使用 PHPStorm,请取消选中Preserve files timestamps
部署选项:https:
//stackoverflow.com/a/42534996/2453148
回答by Connor Leech
Clear the cache and clear the cached blade files:
清除缓存并清除缓存的刀片文件:
php artisan cache:clear
php artisan config:clear
php artisan view:clear
回答by Gabby
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.
或者,如果其他建议的方法不起作用,您可以将文件重命名为不同的名称。刷新其相应的网页以开始使用新的文件名引用。然后,您可以在新页面之后将文件重命名回您的首选名称以反映其更改。
回答by Akhilesh Singh
You can also check if opcache
enabled, in that case you need to clear your opcache cache.
您还可以检查是否opcache
启用,在这种情况下,您需要清除您的 opcache 缓存。
回答by Sigri44
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.
- 从 Nginx/Apache 服务器的 PHP (fpm) 中删除 Cache/OPcache。
回答by HamzStramGram
Like Can Gelis mentionned in a comment. For me the solution was to reload PHP FPM
就像 Can Gelis 在评论中提到的那样。对我来说,解决方案是重新加载 PHP FPM
service php7.2-fpm reload
service php7.2-fpm reload