How to create Hello World using Laravel

Like any other framework or programming language, the first thing we want to do when learning new framework/language is to create a hello world program, because that's the easiest thing to do.

So in this article i will show you how to make hello world program using laravel framework. Laravel is a MVC (Model View Controller) framework, but we are not going to apply a true MVC concept on this hello world program.

For this tutorial, i'm not going to create a new laravel project, instead i'm going to use laravel project that we create on the previous tutorial, which is the project name is "myfirstweb".

Step 1 : Create a view
Okay the first step is to create a view and we are going to called it hello-world.php, on laravel the views are stored in the app/view/ folder, so go ahead create hello-world.php file inside app/view folder.

So it should be myfirstweb/app/view/hello-world.php, and here's the code for hello-world.php

As you can see it's just a regular html page that will output "Hello World".

Step 2 : Add new route
Next we need to add new route, route is laravel feature for handling page request. Route on laravel is manage by the file routes.php under the app folder. So now open routes.php and add following code :

Step 3 : Run the program
Now we can try to run the program, open your favorite web browser and then enter this  url:

You should see something like this:

Congratulation you have just create hello world program on laravel. :)