WEB PROGRAMMING 2 - TP
LARAVEL - INSTALLATION
I. Install any web server having Apache and Mysql
Wamp, Xampp, EasyPhp, etc.
II. Install composer :
Laravel uses composer to manage dependencies
https://getcomposer.org/download/
After installation, type in the command prompt ‘Composer’
2
LARAVEL - INSTALLATION
III. Install Laravel :
Go to your web server root folder
Run the command to create your first Laravel project
Start Laravel services by executing
Open the URL in the browser 3
EXERCISE 1- SIGNUP
The purpose is to create a fully functional Signup
form.
In order, we will divide our work into multiple
steps.
4
EXERCISE 1- SIGNUP
Step 1:
Create the HTML form
Step 2:
Create corresponding route: localhost:8000/Signup
Step 3:
Create user controller
When user clicks the Register button, we need to
display a message
‘Welcome Firstname, Lastname’ 5
EXERCISE 1- SIGNUP
Step 4:
Set database connection string
Create user Model and DB table
Add needed methods ( for CRUD operations)
Step 5:
Set the Signup logic:
Verify email is not already taken
Encrypt password before adding the record to the DB
Display a message to the user 6
EXERCISE 2- GET ALL USERS
Step1:
We need to display the list of users we added in
exercise 1 following the below grid.
7
EXERCISE 2- GET ALL USERS
Step 2:
Add to the above grid , a simple search.
User can search by
Name
Email
8
EXERCISE 2- GET ALL USERS
Step 3:
When user clicks on a record, he will be redirected
to the user details page.
9
EXERCISE 2- GET ALL USERS
Step 4:
When user clicks on edit, he will be redirected to
the below screen to update his info.
When user clicks on delete, show a confirmation
popup before deleting the intended user.
10
EXERCISE 3- MOVIE APPLICATION
We need to build a movie review application using
Laravel where users can:
browse through list of movies
search for movies
check movie details page
leave reviews and rating
11
EXERCISE 3- MOVIE APPLICATION
In this web app, we support two roles:
Admin can:
Add/ update/ delete movies
Delete reviews
User can :
Browse and search for movies
Check movie details
12
Add review
EXERCISE 3- MOVIE APPLICATION
Landing page
List of all movies
each movie has a title, a
thumbnail and a small
description
the movie title is clickable
and redirects to the details
page
Get request
13
EXERCISE 3- MOVIE APPLICATION
Details page
It shows the :
movie title
production year
thumbnail
duration
genre
synopsis
list of reviews
each review has a title, user that
wrote it, date and the description
14
Get request with movie Id
EXERCISE 3- MOVIE APPLICATION
Add review page
The page has a:
title
rating : 1 to 5
content
Post request
15
EXERCISE 3- MOVIE APPLICATION
Search page
User can by search movie title
or description
Results will be displayed as
per the image here
16
EXERCISE 4- RESTFUL WEB API
The purpose of the exercise is to create a small
restful API that will get, add, update and delete
students.
In order, you need to create a new Laravel project
and add the students table to the database.
You will also have to download and work with
postman. 17
EXERCISE 4- RESTFUL WEB API
The API will have the following endpoints:
1. GET /api/students
• will return all students and will be accepting GET requests.
2. GET /api/students/{id}
• will return a student record by referencing its id and will be
accepting GET requests.
• Try to make the call for a non-existing id
3. POST /api/students
• will create a new student record and will be accepting POST
requests.
• Call the get service to validate that a new student is created 18
EXERCISE 4- RESTFUL WEB API
The API will have the following endpoints:
4. PUT /api/students/{id}
• will update an existing student record by referencing its id and
will be accepting PUT requests.
• Call the get service to validate that the record was updated
5. DELETE /api/students/{id}
• will delete a student record by referencing its id and will be
accepting DELETE requests.
• Call the get service to validate that the record was deleted 19
EXERCISE 4- RESTFUL WEB API
General notes:
Routes should be set in routes/api.php
All responses should be of type json
For Post and Put services, the request should be of type json
Make sure to return the correct response code:
200 ok
404 not found
500 internal sever error
etc.
20