我正在使用PHP-FPM在Nginx服务器上工作。我安装了Laravel 4.1
和bootstrap v3.1.1.
,这就是问题所在。在过去的30分钟里,我一直在尝试更改我最初声明要检查boostrap的css规则。
.jumbotron{
background: red;
}
第一次起作用。超大容器是红色的。因此,我删除了该css值并开始工作,但是无论我使用哪个浏览器,该容器都是红色的。我什至通过Google Chrome浏览器检查工具检查了css文件,并且显示了jumbotron带有时的第一个值background:red
。我删除了css文件,并将其重命名并添加了新样式,我将chrome配置为不缓存页面。但是还是一样的价值。我现在确信,Laravel保留了第一个样式声明的缓存。
有什么办法可以禁用此功能吗?
当您访问Laravel Blade视图时,它将生成一个临时文件,因此不必在每次访问视图时都处理Blade语法。这些文件app/storage/view
以文件名(即文件路径的MD5哈希)存储在文件中。
通常,当您更改视图时,Laravel会在下次访问视图时自动重新生成这些文件,然后一切正常。通过比较通过该filemtime()
函数生成的文件和视图的源文件的修改时间来完成此操作。在您的情况下,可能是有问题,并且没有重新生成临时文件。在这种情况下,您必须删除这些文件,以便可以重新生成它们。它没有任何害处,因为它们是从您的视图自动生成的,并且可以随时重新生成。它们仅用于缓存目的。
通常,它们应该自动刷新,但是如果它们卡住并且遇到类似问题,则可以随时删除这些文件,但是正如我所说的,这些只是很少见的例外。
以下所有代码均来自laravel/framerok/src/Illuminate/View/
。我在原件上添加了一些额外的注释。
从Engines/CompilerEngine.php
我们拥有的主要代码开始,我们需要了解其机制。
public function get($path, array $data = array())
{
// Push the path to the stack of the last compiled templates.
$this->lastCompiled[] = $path;
// If this given view has expired, which means it has simply been edited since
// it was last compiled, we will re-compile the views so we can evaluate a
// fresh copy of the view. We'll pass the compiler the path of the view.
if ($this->compiler->isExpired($path))
{
$this->compiler->compile($path);
}
// Return the MD5 hash of the path concatenated
// to the app's view storage folder path.
$compiled = $this->compiler->getCompiledPath($path);
// Once we have the path to the compiled file, we will evaluate the paths with
// typical PHP just like any other templates. We also keep a stack of views
// which have been rendered for right exception messages to be generated.
$results = $this->evaluatePath($compiled, $data);
// Remove last compiled path.
array_pop($this->lastCompiled);
return $results;
}
这将在中完成Compilers/Compiler.php
。这是一项重要功能。根据结果,将决定是否应重新编译视图。如果返回false
而不是返回true
,则可能是无法重新生成视图的原因。
public function isExpired($path)
{
$compiled = $this->getCompiledPath($path);
// If the compiled file doesn't exist we will indicate that the view is expired
// so that it can be re-compiled. Else, we will verify the last modification
// of the views is less than the modification times of the compiled views.
if ( ! $this->cachePath || ! $this->files->exists($compiled))
{
return true;
}
$lastModified = $this->files->lastModified($path);
return $lastModified >= $this->files->lastModified($compiled);
}
如果该视图已过期,它将被重新生成。在Compilers\BladeCompiler.php
我们看到,通过所有刀片的关键字,编译器将循环,并最终回馈包含编译PHP代码的字符串。然后它将检查是否设置了视图存储路径,并使用一个文件名将该文件保存在该文件名中,该文件名是视图文件名的MD5哈希值。
public function compile($path)
{
$contents = $this->compileString($this->files->get($path));
if ( ! is_null($this->cachePath))
{
$this->files->put($this->getCompiledPath($path), $contents);
}
}
最后在Engines/PhpEngine.php
视图中进行评估。它进口传递到与视图中的数据extract()
,并include
与在传递路径的文件try
,并catch
与所有的例外handleViewException()
是再次抛出异常。也有一些输出缓冲。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句