How to make your first Hello World Page in Laravel?

Welcome again Laravel is the most trending MVC(Model View Controller System) in all frameworks. It has a lot of options and a lot of qualities which makes it easy to learn and work fastly. YOu can develop E-mail configuration, push notifications, payment integration, and mobile API in very easy and quick ways. Anyways today I am going to show you how you can create your first Hello World Page using Laravel.

Note: I am using Laragon Localhost for installation and setup Laravel projects if you don’t about it then you can click here .

So we are going to install Laravel and create your first step using these steps.
1-Installation of Laravel
2-Page Creation


1-Installation of Laravel

I am using going to install Laravel using one click on Laragon as it is the best localhost setup for all developers. Let’s begin Laravel installation without wasting our time. You have to go to Laragon, open it, and click on Start All. It will start localhost. After that, you have to go to the Web->Quick app->Laravel. Click on it and it will ask you project name write project name and after that, it will initialize the installation of Laravel by opening a CMD window. You have to wait for a while.

Laravel Installation on Laragon.

Note: You can also download zip file on your local environment using Laragon.

Here you can see How it will start installation of Laravel.

2-Page Creation

Laravel is based on MVC model so you need to understand a little bit about it.

1-For page creation you have to add .blde.php of any view like index.blade.php

2-You can define your different section like header ,footer and sidebar in different manners as Laravel default pages are define in app.blade.php which includes header.blade.php, footer.blade.php.YOu ca call different layouts for different pages.

3-You have to call this view into Controller in the function forms in app->Http->Controllers.

4-After all you have to define route for it in route->web.php file

So now you have basic information about it so without wasting our time let’s start our first-page creation. As I have said first we need to create blade page for it so go to resources->views and create Hello.blade.php page. You can write this code

<html>
<head>
    <title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>

After that you have to create a controller for it in the app->Http->Controllers HelloController.php you can create it manually of by running command. Just run this command

php artisan make:controller HelloController

It will create controller name Hello Controller and it will contain this kind of code.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HelloController extends Controller
{
    public function helloWorld(){
        return 'hello';       
    }
}

After this you have to create route for it so here I have define route in route->web.php page

Route::get('/hello', '[email protected]')->name('hello');

Now you have done everything now you need to access it and go to laravel project and run php artisan server command and enter /hello in the url like localhost/codespcialist/hello in my case I shall enter https://codespecialist.test/hello as I am using laragone .

I hope you will like the article if you like it then please keep on visiting this blog I shall share the beautiful and amazing experience with you. Goodbye till the next post.

Leave a Reply

Your email address will not be published. Required fields are marked *