Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting views folder path

Tags:

php

laravel-4

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.

like image 539
user1995781 Avatar asked Jun 01 '26 18:06

user1995781


1 Answers

Yes I guess it's possible to make it more prone to change. Just get it from the config like so:

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

This is actually an array of paths (folders) for your views. To change it, just look at the /app/config/view.php config file. It should be quite self-explanatory from there.

If you can access $this->app somehow (e.g. in a ServiceProvider), you also can obtain the configured paths by doing:

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

like image 77
Dream4ge Avatar answered Jun 03 '26 08:06

Dream4ge