DEV Community

Cover image for Laravel for Beginners : a Quick Guide - 2
Kartik Bhat
Kartik Bhat

Posted on

Laravel for Beginners : a Quick Guide - 2

Laravel File Structure

Hope you understood my previous post on Laravel's introduction and its installation

Now Let's see, how the installed Laravel folder looks alike and what each subfolder says...

Alt Text

in this articles it is sufficient, if you understand only a importance of the each subfolder you see, again in the upcoming article I will revisit each folder wherever it is necessary... Don't worry about it.. :)

Ok let's start,

app

it is a core part of our Laravel application, major part of the development happens here, so keep in mind this folder play a key role every time.
it has 5 subfolder by default (we can create our subfolder too as a need of customization)

  • Console
  • Exceptions
  • HTTP - very important !!! (it holds all business logic - a controller files under Controllers sub folder)
  • Models - very important too !! (it holds all database connecting related files)
  • Providers - somehow important too :)

bootstrap

it is a folder where application's cache data resides, for now no need to worry about it much, OK
it has one subfolder

  • cache

config

config is one among important folders under Laravel application folder, where all the configurations related to application were defined, Keep it in mind...

database

database folder has a role with respect to database operations of the application, it holds data creation factory files, database table migrations and data seeding logic...
Again Don't worry I will revisit this folder in depth... :)

it has three subfolders in it

  • factories
  • migrations
  • seeders

public

ohho.... its a public place :)
cool : , I means all publicly accessible files were kept here so that application can access these at any time while execution. I hope its enough as of now... I will speak about it again.. :)

it contains folder like js, css, images etc

resources

its a place where all the expected resources of the application lies, as of now you just remember this folder holds all User Interface related files (your html files - under views subfolder)

routes

this folder holds those files, which defines a route; say a key word by how interaction with an application can be achieved, in generally route is an entry point to the application or to its functionality. As of now just concentrate on web.php file under this folder.

storage

this folder holds those files generated by framework, a place where we can get logs related to application's run time behaviour and application uses it to cache some data too...

tests

As laravel provides automated tests; this folder is meant to save those all; ok it is not so important as of now.

vendors

this folder too an important folder among others, it holds all the data of installed/added/adopted third party libraries/plugins, specifically a laravel plugins...

Ok, apart from these; under Laravel folder there is another factor to mention that is .env file

.env file

it an important file where primary configurations of the application resides, it says about many factors that our Laravel application can easily access.

then we have

composer.json

this is too an important file, which says about installed third party libraries and their versions, connects our application to the composer

How Laravel Application Works

now, after visiting file structure of our application, you may rise a point how actually it works or it runs/executes ?
let's see that concept...

after running the application through command prompt you will get an url, Ok hit that url in your browser...

Wait, Let me explain this diagrammatically,

HowLaravelWorks

.
.
.
.
.
.

What You got ? Any hint..... :)
Ok, in simple words, Browser connected to route, route connected to controller , controller connected to model and browser, then finally model connected to the database... right ? I hope you grasped these at least,

Ok technically I can redefine it as - Browser requests through the route, route then requests to controller, controller interacts with the model and model interacts with the database.

More Specifically, request raises from user interface(browser page)
by calling the route, then route shifts the control to the controller, then controller deals with request either processes data or interacts with model to read/write/update/delete operations, then model actually executes controller's expected operations with database then responds back the status to the controller, then controller responds back to the user interface, this as a whole we can call it as MVC interaction.

Ok, Lets see about conceptualizing of M-V-C on code level in my next article.

Hope you understood little about these...

Thank You
Bye :)

Top comments (0)