Overview of Laravel (30 minutes)
•PHP web application framework
•Developed by Taylor Otwell,
•It follows the MVC architectural pattern.
Model-View-Controller
Model (database code)
Database code
Function code
Webpage Webpage
Controller (function code )
Design code
View (design code )
Why Choose
Laravel?
Eloquent ORM for database interaction.
ORM stands Object Relational Mapping
Maps objects to database
Laravel App Eloquent
ORM
Obj 1 Obj 2
No complex SQL queries Database
Different Database Support
Why Choose
Laravel?
Blade templating engine for efficient views.
Layout Home Page Contact Page
Section 1 Menu links Menu links
Section 2 Articles Address Details
Why Choose
Laravel?
Artisan CLI for faster development tasks
Other Features
•Inbuilt Development Server – No apache required
•Database Seeding – For adding Demo data
•Migrations – Tracking database changes
•Support for Cloud services - AWS, Email Service
•Security – Testify to all your application security needs.
Why Choose
Laravel?
Community Strength
PHP Laravel
Project Project
(without framework)
Setting Up
Environment
1. Installing XAMP Server
2. Start the Apache & MySQL services
PHP
Project
(without framework)
1. Create “php_student_reg” database
2. Create students table and insert data
3. Place student_reg.php file in
htdocs/php_student_reg
4. Update database details in student_reg.php
5. Open http://localhost/mysite/student_reg.php
Setting Up
Environment
1. Installing PHP, Composer.
2. Check composer and php version in CMD
3. Configure zip extension php.ini
Laravel
Project
1. Move files to htdocs/mysite-laravel
2. Create users table and insert data
3. Place getusers.php file in htdocs/mysite
4. Update database details in getusers.php
5. Open http://localhost/mysite/getusers.php
Architecture of Laravel
App
Laravel
Lifecyle
ROUT
E
Route is a way to specify how your web application should respond when a user accesses a particular URL
Request Route
ROUT
E
Routes declared in routes/web.php
Controller
Route
http://127.0.0.1/student-form StudentController.php
/student-form
viewForm
Controller
Route
http://127.0.0.1/add-student StudentController.php
/add-student
storeData
ROUTE
METHODS
GET
Controller
Route
http://127.0.0.1/student-form StudentController.php
/student-form
viewForm
POST
Controller
Route
http://127.0.0.1/add-student StudentController.php
/add-student
storeData
REQUEST
METHODS
GET Retrieve Page or Data
POST Submit Data
PUT Update Data
DELETE Delete Data
ROUTE URI CAN BE
SAME GET
Controller
Route
http://127.0.0.1/students StudentController.php
/students
viewForm
POST
Controller
Route
http://127.0.0.1/students StudentController.php
/students
storeData
GET
ROUTE
GET
Controller
Route
http://127.0.0.1/students StudentController.php
/student-form
viewForm
POST
Controller
Route
http://127.0.0.1/students StudentController.php
/students
storeData
GET
ROUTE
GET Laravel App
Controller
http://127.0.0.1/student-form Route
StudentController.php
/student-form
viewForm
Receives Form Page as Response
FORM PAGE
POST
ROUTE
POST Laravel App
Controller
FORM PAGE Route
StudentController.php
Form Submitted /add-student
CSRF TOKEN addStudent
Redirects to Form Page
CSRF
Token
Database Setup in
Laravel
MIGRATIO
N
• Schema Definition: Define and version-control the structure of
database tables.
• Database Seeding: Populate the database with sample or
default data for testing or development.
• Rollback: Ability to undo or rollback database migrations in case
of issues.
• Database Changes in Code: Express database changes using PHP
code, aligning with application code.
MIGRATIO
N
Create Students
Migration
Migration
Generate Table Column
Generate Students Table
Database Table Changes
MODE
L
Model Student Model
Eloquent Eloquent
ORM ORM
Database Table Students Table
Overview of Laravel (30 minutes)
Enjoy Coding!
Thanks!