Laravel framework architecture

Laravel is a MVC framework. MVC means Model View Controller.

Model:

Models are the real-world entities. In other words, models are the real-world entities conventions in the form of data at website. For example, for an online shopping website Products (items), Offers and User are the models. These are associated with database tables and handles the relations and operations. A product may have some offers and discounts. Models are more than stored data. Product model must have some constrains (number of items, cost, conditional offers). A model fulfills all expects of an entity.

View:

View refers the content (HTML pages) which is served to the user/ visitor. For example, when you visit an online shopping website, you are served with lists of items (products), offers, shopping cart, etc. All this content is makeup data (HTML) for displaying in the browser. This makeup is known as a view in MVC.

Controller:

Controller is the bridge between Model and View. It handles the request from the user with logic. For an online shopping site, searching and filtering products, updating the cart, handling user authentication and checkout the payment are some controllers. In MVC, HTML content and database are not directly accessible for the outer world. These are serve via controllers.

also see Django vs Laravel vs Rails

File structure of Laravel:

If you have installed Laravel, then you can easily know the purpose of each file by reading comments inside those file.

Root folderPurpose
appIt contains the Models and Controllers of the application. It also contains all the logic for performing any operation. Models are placed directly inside this folder.
bootsrapThis folder contains the basic setting for starting the application
configThis folder contains all configuration settings of the application like database connection, including core classes, email settings, etc.
databaseThis folder contains the code for database transactions like creating table, modifying columns, adding default rows in database, etc.
publicThis folder is can be seen by the outer world. This is the directory that is to be pointed to the web server. All static assets (like css, js, less, etc.) are placed here. The index.php file in this folder calls the bootstrap folder files and other core files and starts the application. This index.php file receives all the requests and after complex process responses the content to the visitor. In other words, this is the file which transactions with a browser.
resourcesThis folder contains the resources of the application like views, raw assets, language for localization, etc.
routesThis directory contains four files:
  • web.php - routes for traditional browser HTTP requests
  • api.php - routes for API requests (XHR requests)
  • console.php - Closure based console commands
  • channels.php - Socket channel events
storageThis folder stores the local data like sessions, caches, compiled views files, etc.
testsThis folder contains all tests of application
vendorThis folder contains all third party files (dependencies and additional prepackages for plugins) and code files of the Laravel frameworks.

Other important folders and files are:

  • app/ Http: This folder contains controllers and routes. Routes are defined in routes.php and controllers are defined in Controllers folder. This folder contains two more folders. Requests folder handles the form requests and Middleware folder contains middlewares.
  • app/ Exception: This folder contains the exception classes
  • app/ Services:This folder is used for defining new services. By default it contains registrar service (used for registering new users).
  • app/ Providers: This folder registers and binds the services.
  • resources/views: This folder contains the views files.
  • .env: This is a hidden file in root folder of the application. This file contains the private data like database username and password, email configuration data, etc.

Also see Python vs Php vs Ruby programming languages.

Further Reading:



ReactJS with Redux Online Training by Edureka

About Harish Kumar

Harish, a fullstack developer at www.lyflink.com with five year experience in full stack web and mobile development, spends most of his time on coding, reading, analysing and curiously following businesses environments. He is a non-graduate alumni from IIT Roorkee, Computer Science and frequently writes on both technical and non-technical topics.

Related Articles

With the expanding market of mobile apps, the developers are struggling to maintain the code bases for Native apps. M...
5 Elite and Imperative Hybrid App Frameworks
Django is a great framework in python. But all of the hosting do not provide django hosting in their shared or free h...
Cheap Django Hosting
Laravel provides blade template. Blade files are similar to php files and cover all features of php files. In additio...
Blade Template in Laravel 7

Complete Python Bootcamp: Go from zero to hero in Python 3

Top Posts

Recent Posts

The Complete Web Developer Course - Build 25 Websites

Subscribe

Subscribe now and get weekly updates directly in your inbox!