Laravel Application folder structure

In my previous post, I shared about how to setup Laravel in your system and running the server. If you haven’t read it, I will suggest you to first read that and then carry on with this one.

Link of my previous blog post: https://dikshantraj2001.medium.com/getting-started-with-laravel-5c9191cee5d0

It’s very important to know what all you get from the framework that you are going to learn before starting real coding. You should know what all you are getting and how it’s going to make your life easy. So let’s start…..

Folder structure of laravel application

APP Directory:

It contains the core code and functionality of your application is defined here.

BOOTSTRAP Directory:

It contains the app.php file which bootstraps the framework.

CONFIG Directory:

It contains all the configuration files for your app.

DATABASE Directory:

It contains all your files related to database manipulation like migrations, seedings and model factories.

PUBLIC Directory:

It contains the index.php file and all the other required secondary resources like images, js files, css files etc.

RESOURCES Directory:

It contains the view files i.e all your html related stuff is in this directory.

ROUTES Directory:

It contains the routing for your application.

STORAGE Directory:

It contains the log files, session files, compiled blade templates, caches and other files required to run an application.

The storage/app/public directory may be used to store user-generated files, such as profile avatars, that should be publicly accessible. You should create a symbolic link at public/storage which points to this directory. You may create the link using the php artisan storage:link Artisan command.

TEST Directory:

It contains all the files related to automated tests for your application.

VENDOR Directory:

It contains all the composer dependencies files.

WORKING OF A TYPICAL LARAVEL APPLICATION

DISCLAIMER: These all are just fancy words. Don’t get scared by them!!! :)

index.php

First of all I will tell you about the entry point of a laravel application i.e. public/index.php file. All requests are directed to this file by your web server. There’s not that much code in this file. It is just the starting point for your application.

The index.php file loads the Composer generated autoloader definition, and then retrieves an instance of the Laravel application from bootstrap/app.php. The first action taken by Laravel itself is to create an instance of the application /service container.

HTTP / console kernel

Then the request goes to the HTTP or console kernel file depending on the type of request. All the actions that we want to do on the request before actually accessing is done here. Typically, these classes handle internal Laravel configuration that you do not need to worry about. Middlewares and everything is defined here. Don’t be scare with all these names, you will become familiar soon.

Service Providers

One of the most important kernel bootstrapping actions is loading the service providers for your application. All of the service providers for the application are configured in the config/app.php configuration file's providers array. All the third party libraries are registered here.

Routing

Then comes the routing part. All the routings configurations are in App\Providers\RouteServiceProvider file. All the routes from routes folder are loaded .

Last step

Once the route or controller method returns a response, the response will travel back outward through the route’s middleware, giving the application a chance to modify or examine the outgoing response.

Finally, once the response travels back through the middleware, the HTTP kernel’s handle method returns the response object and the index.php file calls the send method on the returned response. The send method sends the response content to the user's web browser.

Laravel Life Cycle

NOTE: For better understanding go to official Laravel documentation, you will find everything there. ALL THE BEST !!!

--

--

--

WEB LEARNER | WEB3 Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Solving Edge Cases in Rails with Active Record Callbacks

HackerRank Solution: Finding the Percentage

Top 10 Mobile App Development Trends to Watch Out in 2022

Why builtonrails.com isn’t built on Rails

Kotlin 101: Hello World

How to Monitor Server via PSI (Pressure Stall Information) and cgroupv2?

Possible future for Swift programming language at schools

En[code] ThunderCore Club: Summary

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dikshant Rajput

Dikshant Rajput

WEB LEARNER | WEB3 Enthusiast

More from Medium

Configuring Stripe Mock and Laravel Sail

implementing custom auth guard in laravel

Laravel Unit Test Cases with Data Provider — Devstringx

Laravel Unit Test Cases

Laravel Security Vulnerabilities Challenge And How to Address Them Using