What is laravel, how to install it?


Laravel is a PHP Web framework that is used to create dynamic web application using PHP Script with MVC Design Pattern.

Laravel is open source, most secure and reliable framework of PHP, it provide routing mechanism to create set of route to manage program code.

How to install laravel

1)  Install composer first

download composer

What is Composer?

Composer is a dependency manager for a PHP programming language that manages the dependencies of PHP software and required libraries. Nils Adermann and Jordi Boggiano developed the Composer. They started development in April 2011 and first it was released on March 1, 2012.

2) create laravel project

composer create-project laravel/laravel scs-app

another way

composer global require laravel/installer

 laravel new scs-app

3) cd scs-app

php artisan serve

Create First Hello World Program in Laravel

go into routes/web.php

Route::get('/example', function ()  
return "Hello World";  

2) Display Hello World Message to Load View

go into resource/views folder
call this view file under View()

Code of hello.balde.php under views folder
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <h1>Hello World</h1>

Code of routes/web.php
Route::get('/hello', function ()  
return view('hello');  

3) Display Hello World Message to Create Controller and Load View

3.1) php artisan make:Controller HelloController
php artisan make:controller -resource HelloController

3.2) create route
use App\Http\Controllers\HelloController;
Route::get('/he',[HelloController::class, 'index']);

3.3) Edit controller class


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HelloController extends Controller
   public function index()
    return view('hello');

3.4) create view under resource/views folder hello.blade.php

Post a Comment


POST Answer of Questions and ASK to Doubt

Post a Comment (0)