Organizing Your Laravel Views
Committed to the LaraBrain by:
at October 28, 2015 11:23 pm
Bring some sanity to your view directory chaos
resources/views directory is the default location for your project views, meaning when you execute
return view('about') in a controller action, Laravel will look for a file named
about.blade.php in your
resources/views directory. However, when working on larger projects dumping all of your views into this directory can quickly become chaotic.
Fortunately you can organize views into logical directories. For instance, inside the LaraBrain application I've created directories called
categories, and others, each representing a corresponding controller. Within each controller I use Laravel's convenient dot-notation syntax to identify the view and its location. For instance to render the
index action view, I execute the following statement:
To render the
popular action view, I execute:
This simple modification to the default will bring a great deal of additional organization to your Laravel projects!