Laravel 5 - Load views blade file from storage folder

牧云@^-^@ 提交于 2019-12-23 14:21:14

问题


Is it possible to load views from storage folder instead from resources\views?


回答1:


Yes, you have a couple of choices.


1. Add another path to your view config file

Open up config/view.php and add your new path to the paths array:

'paths' => [
    storage_path(),
    realpath(base_path('resources/views')),
],

Laravel will return whichever view that matches first, so be sure to sort the paths accordingly.


2. Add a view namespace

Open up app/Providers/AppServiceProvider.php and add your new view namespace:

public function boot()
{
    $this->loadViewsFrom(storage_path(), 'custom_name');
}

With this you can access the views with a prefix like custom_name:

return view('custom_name::home');



回答2:


Yes it is possible.

Just config your view.php file like this

<?php

return
     ['paths' => [realpath(base_path('storage/views')),],

      'compiled' => realpath(storage_path('framework/views')),
];
?>


来源:https://stackoverflow.com/questions/32373644/laravel-5-load-views-blade-file-from-storage-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!