Laravel Blade 视图未显示对它们所做的更改

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24539087/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:44:59  来源:igfitidea点击:

Laravel Blade views not showing the changes made to them

laraveltemplateslaravel-4blade

提问by Vishal Nair

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.

系统详细信息:在 Windows 64 位
MYSQL:5.6.17
PHP:5.5.12
Apache:2.4.9 中使用 WAMP2.5
我通过 composer 安装安装了 laravel。一切都很好,因为最近我的所有视图都停止显示对它们所做的任何更改。这发生在仅使用 Blade 模板的视图上。

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
       

我已经正确创建了刀片文件并用filename.blade.php. 我的视图文件结构 -
views
        -layouts
                   defaults.blade.php
        show.blade.php
        login.blade.php
       

defaults.blade.php

defaults.blade.php

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

       @yield('content')

  </div>
      @yield('footerscripts')

</body>
</html>

show.blade.php

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.

相同的格式运行良好,但突然开始表现得很奇怪。即使多次刷新视图也没有改变,一旦我尝试删除视图页面内的所有内容,它仍然显示在浏览器中。
有类似的问题,但很多人没有接受答案,有一些评分的问题对我不起作用。我还尝试重新安装新的 WAMP 副本,但没有帮助。它仅在我更改其名称时才有效,但如果我将其改回原来的名称,它会再次开始显示它的旧版本。只发生在刀片模板上。

回答by Arthur Shlain

If you use PHP Storm:

如果你使用 PHP Storm:

  1. open menu File → Settings

  2. go to Deployment → Optionssection

  3. then uncheck option Preserve files timestamps

  1. 打开菜单 File → Settings

  2. 转到Deployment → Options部分

  3. 然后取消选中选项 Preserve files timestamps

回答by clarkf

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

我不确定具体细节,但这与filemtime()Windows 中的实现方式有关(可能与此处相关的错误)。

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\Filesystemwhich calls calls filemtime()(see L179-188). Evidently this is failing to report properly on your system.

Illuminate\View\Compilers\BladeCompiler(好吧,它是父类,Compiler)通过检查它的 mtime 来检查自上次编译以来文件是否已更改,通过Illuminate\Filesystem\Filesystem它调用调用filemtime()(参见L179-188)。显然,这无法在您的系统上正确报告。

First, ensure that the app/storage/viewsdirectory 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.

首先,确保app/storage/views目录具有读、写和删除权限。如果这没有帮助,最简单的解决方案是app/storage/views/在进行更改时清除目录。

回答by LukePOLO

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

我有同样的问题,原因是我正在远程上传,但我计算机上的时间与我服务器上的时间不同

回答by xngigez

  1. In your cmd(command prompt) or terminal type and press enter... php artisan view:clear
  1. 在您的 cmd(命令提示符)或终端中输入并按 Enter... php artisan view:clear

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

为此,您的终端应指向 Laravel 安装/文件夹的根目录

  1. Or delete files in the folder storage/framework/views
  1. 或者删除文件夹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.

为了避免每次重新加载时解析 Blade 文件,Laravel 设计为在解析 Blade 后缓存视图,以避免在每次重新加载时重新解析 Blade。

  1. Or make sure you are editing the right view, in the right Laravel Installation.
  1. 或者确保您在正确的 Laravel 安装中编辑正确的视图。