1

I am getting the views folder path with this: app_path()."/Views"

Is there any better or more solid way of getting the views folder path? I mean, just in case the view folder is moved to somewhere else and it still works.

Thanks.

4

1 回答 1

9

是的,我想有可能让它更容易改变。只需像这样从配置中获取它:

Config::get('view.paths');

这实际上是您的视图的一组路径(文件夹)。要更改它,只需查看/app/config/view.php配置文件。从那里应该是不言自明的。

如果您可以通过$this->app某种方式访问​​(例如在 ServiceProvider 中),您还可以通过以下方式获取配置的路径:

$this->app['config']['view.paths']

于 2013-11-08T09:36:17.853 回答