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
You will see 10 folders which are as follows:-
I am not going into the full detail of each and every folder ; however, i will give you a brief rundown of each folder.
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.
This folder as the name already suggests is used to bootstrap laravel (startup laravel page that you see after installing)
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.
This folder contains our database files such as migrations and seeds
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
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.
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.
As the name suggests this folder of the laravel is used to store the session, caches , and logs in this folder.
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
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
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