Thursday, 14 March, 2019 UTC


Summary

Laravel is a PHP based web framework. Laravel is free and open-source Framework. Laravel is used in both small and large full-featured web application. Laravel Architecture follows MVC Pattern. Here we will see the Laravel MVC structure. Laravel has lots of features which will improve the speed of web development. In this article, we also see the Pros and cons of Laravel.

Laravel

  • Developer: Taylor Otwell
  • Written in: PHP
  • Website Built in Laravel: Deltanet, Neighborhood Lender, MyRank, Laravel Tricks etc
  • Latest Version: 5.7.13
  • Installation: Laravel

Laravel Architecture

Laravel Architecture follows MVC Pattern. MVC stands for Model View Controller. The Architecture of Laravel changes as per the version of Laravel. Here we see MVC implementation in Laravel.
Laravel Architecture
Model
As we all know about Model in MVC, it manages the data in the database or any storage of the application. In the Laravel app, Model is class with properties. In short, if you develop any project Student in Laravel and you create some class with a unique name then it will be the model of your tables and columns are properties in the database.
Student Properties
  • Name
  • Department
  • Enroll No
To create a model in Laravel, run the command
$ php artisan make:model Student
Using this command, Laravel will create a Student.php file in the directory. This will be a PHP class with the name Student. It will be the model for our table Student in the database.
View
In the MVC Pattern view is used to display data. If we discuss Views of Laravel then all the views are stored in the directory resources/views. For example, you create a student.blade.php file then it is stored in a resources/views directory of our project. That file contains code and View display the page.
Controller
In the MVC Pattern Controller is used to handling the request. With a single line of code, Laravel resource routing assigns the typical “CRUD” routes to a controller. It works as a directing traffic between Views and Models. If you wish to create a resource controller then run this command.
$ php artisan make:controller StudentController -r
Laravel will create a new file in the app/Http/Controllers directory called StudentController.php. The controller includes a method for each of the available resource operations. Resource Controller handles many actions like Get, Post, Delete, Put, Patch etc.

Features of Laravel

  • Routing
  • Schema Builder
  • Include mail class
  • Modularity
  • Testability

Pros of Laravel

  • Scalable
  • Includes namespaces and interfaces
  • Reuses the components

Cons of Laravel

  • Sometimes break application when you move Laravel 4 to 5
  • Upgrades might be problematic
  • Heavy documentation
If you want to create any web application in PHP then Laravel is the scope for you because it is easy to use and design is more structured. In Laravel, you can reuse existing components from other framework and develop an application. If you know the basic fundamentals of PHP and Core PHP then it is very easy to develop an application in Laravel.

See More: JavaScript Framework

The post Laravel Architecture appeared first on I'm Programmer.