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 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 shopping site, searching and filtering products, updating the cart, handling user authentication and checkout the payment are the some controllers. In MVC, HTML content and database are not directly accessible for 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 of 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 outer world. This is the directory that is to be pointed to 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 of the requests and after complex process responses the content to the visitor. In other words, this is the file which transactions with browser.
resourcesThis folder contains the resources of the application like views, raw assets, language for localization, etc.
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.

More Tutorials on laravel in this series:



About Harish Kumar

Harish is an interested person in the field of web development and blogging. He works for the need of young web developers in learning various languages, latest technologies and other essential tips and tricks. If you need some help or you have some suggestion then you email him at harish@findalltogether.com without any hesitation. You can also suggest/demand for articles of your own choice.

Related Articles

Laravel is a MVC framework. Models are the real world entities in data form. Views are the response content to the vi...
Laravel framework architecture
Routes map urls with the controllers. In this section we will read about how route maps urls with controllers and how...
Basics routing and controllers in laravel 5
Views are the HTML content served by the server. These are served by returning from controllers. Views are .php or .b...
View in Laravel 5

Login or Sign up to leave comment.