Understanding Laravel Directory Structure


Understanding Laravel Directory Structure

So you are now ready with your Laravel Installation and the next thing you are trying to get your head around is Understanding the Directory Structure in Laravel 5. This is a simple tutorial to help you understand the folder structure in Laravel and to provide information about what thing goes in which folder.

This is how the default Laravel Directory Structure looks like

Let’s understand the role of each folder and file

The Folders

app: the app is where the majority of your application code resides. Model, Controllers, Middlewares, Service Providers. This is the folder you will be working in for the majority of your business Logic development.

bootstrap: This folder contains the files that Laravel Framework uses to boot the framework when it starts.

config: This folder contains the different configuration files related to the database, file system, logging, etc.  Each configuration file returns an array that denotes the configuration values the framework needs to use for your application.

database: This is where the database migration files and the seeds live.

public: This is the public-facing directory. It contains the index.php file which is the first file to be instantiated by the Laravel framework. It also contains public-facing assets such as CSS, images, and js.

resources : This is where the non-PHP files that are needed for other scripts live. Views, language files, Sass / Less, and source javascript files live here.

routes: This is where all your application routes go in. HTTP web routes, console routes, and API routes all go in here.

storage: Cache files, log files, and other compiled system files live here.

tests:  This is where the application tests live. Unit tests, Feature tests, and Automation Dusk tests all go here.

vendor:  This is where the composer installs its dependencies. This folder is git-ignored which means when you commit your source in git this folder is ignored. It is expected to download the dependencies via composer on your remote servers.

The Files

The root directory also contains the following files

.env and .env.example: There are files that contain environment variables. These are the variables that you expect to be changed with each environment. Therefore .env file is git-ignored. You are supposed to have a separate .env file on each environment with a different set of variables. .env. an example is a template file provided to help you create a .env file

artisan: This file allows you to run the artisan command from the command line on the project directory root.

.gitignore and .gitattributes: These are git configuration files.

composer.json and composer.lock: There are configuration files for Composer. Composer.json contains the project package dependencies and composer.lock is a non-editable file and it locks the dependencies of your project to a known state.

package.json: This is like composer.json for your front-end dependencies.

phpunit.xml: This is the configuration file for PHPUnit, the tool Laravel uses for testing out of the box.

readme. md: File to give out basic information about the Laravel Framework.

server.php: is a backup server that tries to allow less-capable servers to still preview the Laravel application.

webpack.mix.js: Mix provides a clean, fluent API for defining some Webpack build steps for your Laravel application.

That’s all, Hope you now Understand Laravel Directory Structure.


Post a Comment