Laravel Fact — Avoid using __DIR__ and __FILE__ in views

As you know already, Laravel has its own templating system, Blade, and it is very convenient to use. However, while in Blade views, you should avoid using these two PHP magic constants __DIR__ and __FILE__.

At first time, when view is created and loaded, it will generate a cache file for view, which is put under storage/framework/views directory. Next time, when the users ask for the view, Laravel will actually load the cached version, not the one under resources/views. So, those two magic constants will return the path under view cache directory, as mentioned above storage/framework/views.

Final words, avoid __DIR__ and __FILE__ in Blade views.