Laravel Directory Structure

Previous Chapter

Laravel Directory Structure contains many folders, sub-folders & files. when we download laravel project this whole directory structure of laravel downloaded automatically as a project.


Laravel Root Directory Structure

Below given snapshot show you root the main folder of laravel project which contains many folders, sub-folders & files. All folders and files explanation is given below.

Laravel Root Directory Structure

This Laravel root directory is the main directory that contains many other directories.

In snapshot “MATCH4U” is the Laravel project name your project name might be different.

DirectoryDescription
appThe app directory is a base directory that contains Controller, Middleware, Exception, Event, etc.
bootstrapThe bootstrap directory contains all bootstrap scripts that are useful for your web application. it contains subfolders called cache to use caching mechanism.
configThe config directory holds configuration files to configure laravel web application.
databaseThe database directory contains all required database files.
publicThe public directory is the main root directory which is used to start your laravel application. it contains all required assets like CSS, JS, Images, etc.
resourcesThe resources directory holds files which use to make an advance web application, Which contains Saas files, Lang, Views.
routesThe Routes directory includes files for routing such as console, API, channels, web, etc.
storageThe storage directory contains files for the session, cache, log, and other miscellaneous files.
tests The test directory contains all your application test cases.
vendorThe vendor directory includes all composer dependencies files.

The App Directory Structure in Laravel

The App Directory Structure in Laravel

1. Console

The console directory holds all your project artisan commands, The other file is Kernel.php.


2. Exceptions

Exceptions directory contains all your web application exception handling files, which handles exceptions that occur in the laravel project.

It also contains a default file called handler.php to handle exceptions.


3. Http

The Https Directory contains sub-folders for controllers, middleware & requests files.

where,

Controllers Folder

The Controllers folder contains files to handles all your web application requests.

– Middleware Folder

The Middleware folder contains middleware file to filter between request and response.


4. Providers

The provider’s folder holds files of service providers for core servers and configures the laravel application.


The Bootstrap Directory Structure in Laravel

The Bootstrap Directory Structure in Laravel

1. Cache

Cache Directory contains files for caching a web application.

the other file called app.php holds scripts for bootstrap.


The Config Directory Structure in Laravel

It contains all configuration files for laravel web applications.


The Database Directory Structure in Laravel

The Database Directory Structure in Laravel

1. Factories

This folder contains a file called UserFactory.php which is used to generate large numbers of users.

2. Migrations

Migrations folder helps to migrate the database in the web application.

3. Seeds

The Seeds contains classes for database unit testing in the laravel application.


The Public Directory Structure in Laravel

The Public Directory Structure in Laravel

1. CSS, JAVASCRIPT, IMAGES

These folders contain CSS, Javascripts & images that we have used in our laravel web application.

2. .htaccess

This file contains server configurations for your web application.

3. Index.php

This file used to initialize your laravel application.


The Resources Directory Structure in Laravel

The Resources Directory Structure in Laravel

1. lang

The lang folder contains files to configure localization and internationalization.

2. Views

The views folder holds HTML & blade template files that interact with end-users. view is really important to serve User interface to users & it’s a part of MVC.


The Routes Directory Structure in Laravel

The Routes Directory Structure in Laravel

1. web.php

Web.php contains a definition of each route of the web application. it’s a file where all URLS are defines.


The Storage Directory Structure in Laravel

The Storage Directory Structure in Laravel

1. app

The app folder holds a file that are executed in succession.

2. framework

This contains cache, sessions & views related folders.

3. logs

The log contains a logs file for error & exceptions.


The Test Directory Structure in Laravel

The Test Directory Structure in Laravel

As the name suggests it contains all unit test cases of laravel web application. test case name follows camel_case.


The Test Directory Structure in Laravel

The Test Directory Structure in Laravel

As the name suggests, it contains all unit test cases to test your laravel web application. the test cases name follow camel_case naming convention.


The Vendor Directory Structure in Laravel

The Vendor Directory Structure in Laravel

The vendor directory contains all composer dependencies which are used to install any third-party libraries, utilities, etc.

Others File in Laravel Directory Structure

Others File in Laravel Directory Structure

These files also play an important role in many functionalities such as environment setting, GitHub configuration, Packages & third-part libraries for smoothly running laravel web application.

Previous Chapter

Leave a comment