Beginners Laravel

Laravel 5 Hello World Application

Google+ Pinterest LinkedIn Tumblr

Today, We are going to learn how to use laravel by creating Laravel 5 Hello World Application step by step. In this, we are going through the basic of Laravel 5 Hello World application by creating Laravel Route, Controller, View.

Introduction

Laravel is a full-framework for all kind of application. Hence, Laravel is the most popular highest rating framework on Github. Laravel is easy to use, with a simple learning curve, and a minimum number of steps required to get an app or website up and running.

First of all, We are going to install Laravel by following this steps.

Laravel 5 Hello World Application

We are going to learn Laravel 5 Hello World Application step by step.

Route

A route is a URL pattern that is mapped to a handler. Laravel route directs an incoming request to function or controller. Also, a route is a store on the “routes” directory. Let’s create the route for Hello World Application.

Let’s Open “routes/web.php” file for creating the route.

Laravel allow us to call view file directly from the Route. Now, let’s create the route that calls view file from Controller.

Finally, The Route is ready for “Hello World” application Now, Let’s move for the Controller.

Controller

Instead of defining all of your logic in the route files,  You may wish to create Controller class for organizing the logic. Controllers can group related request handling logic into a single class. Controllers are store in the app/Http/Controllers directory.

Let’s create the “HelloworldController.php” File at the “app/Http/Controllers” Folder or else we can generate Controller file by following artisan command like

After, Creating the Controller let’s create the “HelloWorld” method like

Finally, We are ready with Controller. We just call view file using Controller class instead of the Route. Now, let’s we are going to create the view file.

View

View file contains the HTML served by your application and separate your controller/application logic from your presentation logic. Views are store in the resources/views directory.

Finally, We are ready for the Laravel 5 Hello World Application. Now, let’s run the application and see the output.

Run laravel application by the following command

Now, Running the Laravel 5 application by following URL “http://localhost:8000/hello-world”

Output get something like this.

LaravelHive – Laravel 5 Hello World!

Leave a Reply