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
<?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.
<!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.
It creates local server (Laravel development server started: