storage/framework/views和resources/views在Laravel中的区别

The difference between storage/framework/views and resources/views in Laravel

我不太了解文件 laravel_core/storage/framework/views 和 laravel_core/resources/views 之间的区别。 在这两个目录中都有刀片服务器,但不相等,存储视图的名称是随机的。

这是文件示例的图片:

图片:1

图片:2

  1. resources/views

resources/views中是您创建和修改的视图。见 Laravel 8 documentation:

Views contain the HTML served by your application and separate your controller / application logic from your presentation logic. Views are stored in the resources/views directory.

  1. storage/framework/views

作为 documentation explains:

By default, views are compiled on demand.

除非 up-to-date 的编译视图已经存在。这些被缓存并存储在 storage/framework/views 中,这就是它们看起来如此难以理解的原因。另见 ServerFault answer:

The view cache is always stored via the filesystem in storage/framework/views.

顺便说一句,如果你想预编译它们,你可以使用命令

  • php artisan view:cache

并清除它们

  • php artisan view:clear

除了这两个命令之外,您不太可能需要对已编译的视图执行任何操作。您使用“普通”视图、创建它们、编写代码等。