Categories: Laravel Tutorial: Step by Step Guide to Building Your First Laravel Application - Techanical-Atom

Laravel Structure Explained In Detail Beginners Guide4 min read

EXPLORING FILE STRUCTURE
Reading Time: 3 minutes

Laravel Structure Explained In Detail Beginners Guide:-  When you install any laravel app you are accompanied by the predefined files and structure of laravel gets downloaded into your system which contains many files and folders. In this article we are going to cover each of these files and folder and i am going to explain the task and meaning of each one of it. So let’s begin the learning.

Laravel Structure Explained In Detail Beginners Guide

A solid structure is essential for making your app efficient and awesome. Some developers are used to ruin and destructed the structure but as a beginner and with my help , you will get accustomed to a solid foundation and structure.So here is how the laravel file struture looks like

Laravel Structure
Laravel Structure

You will see 10 folders which are as follows:-

  1. app
  2. bootstrap
  3. config
  4. database
  5. public
  6. resource
  7. routes
  8. storage
  9. tests
  10. vendor

I am not going into the full detail of each and every folder ; however, i will give you a brief rundown of each folder.

 1) app

This is the directory that has all our applications logic and all the good stuff is stored here.In this folder, we will put all of our modals, controllers, services , and many other classes.

2) Bootstrap

This folder as the name already suggests is used to bootstrap laravel (startup laravel page that you see after installing)

3) Config

This folder contains many of our global configurations for our application. It contains files like app.php,auth.php ,broadcasting.php and many more along with this.

4) Database

This folder contains our database files such as migrations and seeds

5) public

This public folder contains many of the application assets such as images,stylesheets,and scripts. Along with these this folder also contain .htaccess and index.php (which contains the code to start the laravel application using the autoload.php and bootstrap files)

Read More:- WHY LARAVEL IS THE BEST PHP FRAMEWORK IN 2018

6) Resources

We will put all of our view files in this folder. The views are the pages that a user sees and it uses the blade templating engine which  is one of the awesome feature that comes along with the Laravel.

7) Routes

This folder contains all the routes for our application. This includes console , API, and web routes. Primarily we will focus on the web.php route file in this folder as this is the file which contains all the routes for our application.

8) Storage

As the name suggests this folder of the laravel is used to store the session, caches , and logs in this folder.

9) tests

This folder contains files that we use to test the logic of our application. Laravel uses the Unit test of test all the logic  of the application which is quite awesome as for a beginners it is very essential to test his/her application before making it live on the server

10) Vendor

This is the folder that contains our dependencies. When you add new libraries to your app , this is the folder that will contain those libraries. SO it is one of the most important folder among the others.

Now do you recognize the composer.json file form the image above.? Remember this is where we define our dependencies for our app.

One important other file mentioning here is .env file , this is the file that contains configurations like debug mode and database credentials. So, when you need to connect a database to your laravel app you will need to update the following code in this file.A simple .env file looks like the following

APP_ENV=local
APP_DEBUG=true
APP_KEY=YOUR_API_KEY
DB_HOST=YOUR_HOST
DB_DATABASE=YOUR_DATABASE
DB_USERNAME=YOUR_USERNAME
DB_PASSWORD=YOUR_PASSWORD
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null

I hope this should have cleared some of the things about laravel file structure for you. This is one the most basic stuff about the laravel that every laravel developer must known in order to have a clear perspective about the awesome framework known as Laravel. Thanks for reading. Cheers ! Happy Coding 

Laravel Documentation can be found here -> Laravel Documentation

All Rights Reserved @ Techanical-Atom
%d bloggers like this: