CodeIgniter Laravel PHP Example Javascript jQuery MORE

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 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() }}">
<title>Hello World</title>
<h1> Hello World</h1>

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 ( we'll get the output.