1/54
SIR SANTI
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
MVC Framework
Architectural pattern that separates an application into three logical components: Model
MVC Usage
MVC is one of the most frequently used industry-standard web development frameworks
Model Component
Corresponds to all data-related logic that the user works with and can retrieve
View Component
User Interface for the users of the application
Controller Component
Acts as a bridge between View and Model — handles user requests
Benefits of MVC
Separation of business logic and presentation
Benefit 2
Allows independent changing/updating of model and view
Benefit 3
Enables code reusability
Benefit 4
Improves code maintainability
Benefit 5
Increases speed of application development
Benefit 6
Allows division of tasks among programmers
Disadvantage 1
Complex even for small projects
Disadvantage 2
Requires proper understanding to avoid misuse
Disadvantage 3
Has slight performance overhead compared to procedural code
Choosing MVC Framework
We must choose a programming language and MVC framework before development
Popular MVC Framework: ASP.NET
Supports multiple programming languages (C# most popular) and is cross-platform
Popular MVC Framework: Django
Uses Python and includes many universal modules
Popular MVC Framework: Ruby on Rails
Good for business and high-speed development
Popular MVC Framework: Laravel
Uses PHP and offers high security
Laravel Framework
Laravel is a web application framework with expressive
Why Laravel?
OOP approach
Why Laravel? (2)
Built-in authentication
Why Laravel? (3)
Templating engine (Blade)
Why Laravel? (4)
Eloquent ORM
Why Laravel? (5)
Security via csrf_token
Why Laravel? (6)
Excellent documentation
PHP for Selecting Laravel Version
Choose compatible PHP version for your Laravel release
Routing (Basics)
Defines how your app responds to different URLs
Routing Methods
Determine HTTP methods (GET
CSRF Protection
Prevents Cross-Site Request Forgery attacks using a CSRF “_token” for each session
CSRF Tokens
Required for POST
Redirect Routes
Redirects a user to another URL or route
View Routes
Displays a specific view when accessed
Route Parameters
Allows dynamic data in routes (e.g.
Route Parameter Constraints
Restricts route parameters using conditions
Route Name
Assigns name to routes for easy reference
Route Group
Groups routes sharing attributes (like middleware)
Route Prefixes
Adds common prefixes to grouped routes
Form Method Spoofing
Allows HTML forms to simulate PUT
Controllers
Acts as intermediary between Model and View
Single Action Controller
Controller that handles only one action or method
Resource Controller
Generates CRUD routes and methods automatically
HTTP Request
Laravel handles requests using OOP-based Request class
Blade Templating Engine
Simple yet powerful templating system used for Laravel views
Validation
Ensures data is correct before saving to the database
Validation (Return in View)
Displays validation errors in view after submission
Validation Rules
Set of predefined rules for validating form input
Eloquent ORM
Object-Relational Mapper that simplifies database interactions
Eloquent Example
Model example with table
Eloquent Relationships
Defines relations between tables like One To One
Eloquent Relationship Types
Has One Through
Getting Started with Laravel
Requires Composer
Creating New Application
Use command: composer create-project laravel/laravel=
Running Laravel App
Use terminal: cd
Access Laravel App
Open browser and go to http://127.0.0.1:8000