[英]Laravel 5 - Load views blade file from storage folder
是否可以从storage
文件夹而不是从resources\\views
加载resources\\views
?
Yes, you have a couple of choices. 是的,你有几个选择。
Open up config/view.php
and add your new path to the paths
array: 打开
config/view.php
并将新路径添加到paths
数组:
'paths' => [
storage_path(),
realpath(base_path('resources/views')),
],
Laravel will return whichever view that matches first, so be sure to sort the paths accordingly. Laravel将返回首先匹配的视图,因此请务必相应地对路径进行排序。
Open up app/Providers/AppServiceProvider.php
and add your new view namespace: 打开
app/Providers/AppServiceProvider.php
并添加新的视图命名空间:
public function boot()
{
$this->loadViewsFrom(storage_path(), 'custom_name');
}
With this you can access the views with a prefix like custom_name
: 有了这个,您可以使用类似
custom_name
的前缀访问视图:
return view('custom_name::home');
Yes it is possible. 对的,这是可能的。
Just config your view.php file like this 只需像这样配置你的view.php文件
<?php
return
['paths' => [realpath(base_path('storage/views')),],
'compiled' => realpath(storage_path('framework/views')),
];
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.