Laravel Tutorial Day 1

Learning Objectives: To understand the fundamental about PHP Laravel, Installation and Hello World Example.

Install LAMP into Ubuntu

Reference Website to Install Composer in Ubuntu

sudo apt update

sudo apt install php-cli unzip

cd ~
curl -sS -o composer-setup.php

sudo php composer-setup.php –install-dir=/usr/local/bin –filename=composer


Install Composer

Install Laravel

Create Hello World Project (First Project using Laravel)

Goto Command Prompt (use cmd command)

goto specific folder (eg. c:\laravelproject)


md laravelproject

cd laravelproject

Now Create project (Laravel Project Create Command)

composer create-project laravel/laravel myapp1

cd myapp1

php artisan serve

Now Test Hello World in your Browser

Open Chrome Browser (Or Firefox Browser / other)

Open URL:

Laravel Tutorial Day 2

Learning Objectives: To understand URL to Access and Management of Laravel Routes. Routes are the way to setup some view/controller for the specific URL.

When user opens the home page we would like to display some content from the view (view name for this example is welcome)

So first create view name: welcome with the following code:

Welcome to Laravel Training Home Page

Now we need to setup the route into route file. Here ‘/’ means home page url, sample code will be as follow:

Route::get(‘/’, function () {
return view(‘welcome’);

Now if user wants to open then we would like to fetch content from about view then route will be as follow:

Route::get(‘/about’, function () {
return view(‘about’);

Make sure to create about view before writing this route information.

When you wish to collect parameter information from the URL, and wish to transfer this information to view, then sample code will be as follow:

Route::get(‘/service/{name}’, function ($name) {
$data = compact(‘name’);
return view(‘service’)->with($data);

{{ $name }} Services

Now you can able to Create various Views & Routes to setup different content for different URLs.

Practice Examples:

Create Simple Website with following Pages:

  1. Home Page (URL: )
  2. About Us (URL: )
  3. Services List (URL: )
  4. Service Detail (URL: )
  5. Contact Us (URL: )

Laravel Tutorial Day 3

Learning Objectives: Till now you have learned the basics about the laravel to create pages and setup urls of the website. Now its time to learn the core element structures like loop, conditions, and so on.

PHP Laravel if elseif endif Examples:

@if (count($records) === 1)
I have one record!
@elseif (count($records) > 1)
I have multiple records!
I don’t have any records!

PHP Laravel switch Examples:

First case…
Second case…
Default case…

PHP Laravel for loop Examples:

@for ($i = 0; $i < 10; $i++)
{{ $i }}

PHP Laravel foreach loop Examples:

@foreach ($items as $item)
{{ $item->name }}

PHP Laravel while loop Examples:

@while ($i < 10)
{{ $i }}

For more fundamental syntax have a look @ Official Laravel Docs