CodeIgniter Laravel PHP Example HTML Javascript jQuery MORE Videos New

Hello world example - Laravel framework


In this example we will discuss about Hello world example laravel framework PHP.

For hello world example we need to do minimum two things.

1.go to web.php (route folder) and create route

web.php

<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
            return view('welcome');
});

Here we can see we created one root route(/) with get method( http method ) and in like callback style we return.

A view welcome (resources/views/welcomel.blade.php ).

2. Create/open welcome.blade.php file and put the code.

welcome.blade.php

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<title>Hello World</title>
</head>
<body>
<h1> Hello World</h1>
</body>
</html>

We have two way to run this example.

  1. If our system installed any local server like MAMP, XAMPP,WAMP etc.
  2. Otherwise, one terminal go to project directory and run the artisan command php artisan server.

It creates local server (Laravel development server started: ) and In browser when we hit root route (http://127.0.0.1:8000/) we'll get the output.