Directory Structure in Laravel | Laravel 8
By: Rajat Verma
Tags: Laravel Development, Laravel 8, Directory Structure, Laravel

image-source: pixabay.com

In this article we will talk about what is the directory structure of larval 8 so for those guys who are already familiar with the larval 5,6,7 for those there is not a huge changes into the larval 8 and they can just go through with the what is new in the laravel 8 article right and they can proceed to the next this article is specially designed for the new person who is new in laravel so the directory structure is one of the important thing in any framework right so we need to understand that what is the directory structure of laravel a drive so directory structure means how the directory are placed in the frameworks how the files are placed in the frameworks right which file is important and which file we can get at which directory right so if i talk about laravel 8 so you guys can see here in previous article that i have installed a pizza larval application that is larval 8 into my ubuntu 16.04 lts version right so in the laravel 8 we have a like in our main folder we have a app directory bootstrap config database public resources routes storage test vendor and some important files right.

Directory Structure (Laravel 8)

So let’s start with the one by one and we will talk about each and every directory right first of all the app directory right app directory is the one of the most important directory right or you guys can say that all the code which we write for the application is contained under the app right most of the things we have into the app that is our middleware our controllers our models our exceptions anything related to the console command sright so that all comes under our app so ninety percent of the code we write in the laravel that all comes under the app direct right we have a controller middlewares then we have a model and here i want to repeat one thing that in laravel 8 we have now new directory of models right before we do not have any model directory right so that is a new feature added into a laravel 8 right then we have our providers right so this is about app directory this is an important directory used to place our controllers models providers middlewares right so next thing is bootstrap right so bootstrap is basically used for the booster we know the bootstrap frame work of css right so for the caching right so that is for that purpose and then we have a config which is now the another important directory after app directory right in this we have the configuration of our laravel 8 application right we have a app.php or .php cache header cache settings then we have our database connections file systems then hashing logging mail setup queue setup services session setup view dot php so every kind of configuration which can be done into laravel 8 application is available into the config directory.

image-source: pixabay.com

So config directory as it is may clear from from its name so it is used for the configuration right so the next thing is the database basically So i have some sub directory like cedar seeders and migrations factories right so the basically these these directories basically used with the database kind of work right for the migration files for the seeders file right cedar means when you want to add a large amount of data into your database correct then we have a migration file then some factories file right so you guys can see the factory is also added new into our laravel 8 right then database sowe can say that the database is also a very important directory right so those guys who are new into laravel 8 i just want to tell you that database migration like creating tables alteration of tables creating databases everything is dynamic in the laravel 8 or laravel versions right we do not need to go into the php my admin or my sequel to create the tables and all we just we execute our artisan command and we are able to execute the migrations right so this is for that then we have a public folder right so what is the job of public folder public folder is basically you guys can say the entry point right here we have in public folder we have an index dot php right so index dot php is the one of the you guys can say the entry point of the larval application so whenever you load the laravel application right we run command php artisan serve then automatically we got that 127.0.0.1 colon 8000 right so that page which execute that is index.php so the first entry point is index.php and more in the public directory is that we can add images or the external files like js file external files we can put into the public directory right then resources is similar we can say the resources basically the static files we have like we have css file js files right these kind of file then we have some language kind of configuration right then we have a views views is basically html part so all the views that is loaded by the different different controllers are actually placed into the views director right we can create a multiple directory into the views directory butwe contain all the views into our view directly then next after resources the next which is the most important thing to understand into the larval that is for the routing right how we can do the routing so the routes folder is basically handle the files which is used for the routing purposes right for the api routing so whatever the url generated for the api’s.

We write into the api’s right for channels we have a different routing for console we have a different writing for a web right web means whatever we call from the https request console mean that we run through the cli right so routing if i say in simple word routing is basically a configuration of your url routing right so that is again an important directory then we have a storage directory in the storage directory basically we store the cache or logs right so this is again important and one thing i want to mention here that the storage directory should have the permission of 777 right because it should be writable because here the we have to write down the logs at runtime right then we have test then test is another perspective to testing it’s a very important directory for example unit testing or any automation kind of testing we need to add on that we used into the test so the next very important directory is vendor directory so the vendor directory basically we know that that we have installed the composer using we have used composer to install laravel late right so we haven’t installed different different dependency which is used by the larval so in the vendor directory we have the all the dependency all the library third parties dependencies services or library that all include into the vendor directory right so this is all about the directory and if i talk about another important files that is present into the my laravel application that is my first of all dot env that is an environment file in which i mention all the parameters variables right which is used for the development mode right so you guys can see here if i click here so you guys can say app name app key right db connection all these things are available right so this is basically used for the environment variables right then important thing for for a beginner to understand the artisan file right so artisan file is basically contain all the artisan commanory right so this is all about the directory and if i talk about another important files that is present into the my laravel application that is my first of all dot env that So the person who do not have a much knowledge about artisan command just go into the into your application and run that command php are teasing right so you guys will automatically get the all the command which is used by the artisan right php artisan and also description of the commands so this is a very beautiful thing according to me so you guys can do this way and can understand each and e and every file which is used into the laravel application right so the next important file is that is composer.json right this is again related with the composer in which we have all the dependency mentioned right then we have a composer lock file which is important right then readme is about the i nformation about the larval right how to run that this kind of information then we have a server.php the information regarding the server so at the beginner level we just need to have a very good information about app directory config directory database data directory the resources route storage vendor env variable and artisan file right if you guys have a basic understanding of these directory and these two three files that is enough for a beginner so hope you guys enjoy this session so if you guys have any query question you guys can comment into the comment box. The next time we upload the article because now we continuously uploading the article for the larval a try so please do allow to enable the notification alert at top-left corner so thanks for reading have a very good day.

Officially Published On — https://querycounter.com/post/68/directory-structure-in-laravel-laravel-8