Laravel PHP Learning tutorial class 5

Laravel Hello World

After the above step, open CMD and hit the composer –version. You should receive the  Composer version information. That’s it! The setup was successful.


After composer installation, Write following command in command line.

After above installation, create a directory in apache24 or xamp directory, then go to command line and set your created directory.

Then write the following command into a command line.

composer createproject anvar

where, anvar is the name of the project.

Now, create your first application.

Create a controller in /app/Http/Controllers/anvar.php  and write following code in it.

namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppHttpRequests;
use AppHttpControllersController;
class Anvar extends Controller
     * Display a listing of the resource.
     * @return Response
    public function index()

namespace AppHttpControllers : defines the namespace for our controller.
use IlluminateHttpRequest | use AppHttpRequests | use AppHttpControllersController : imports namespaces with the required classes to run the controller.
class Alphansotech extends Controller defines the class for the controller. The controller extends the base controller.
public function index(){ ….. } : defines the default function for the controller.

Now, navigate to app/Http/route.php and write following code.

    return ‘Hello, This is Anvar Laravel step by step guide.’;

Now, open the following URL in the browser.


we can also call a view file from here, to call , we need to create a view file which renders the HTML output.

Laravel uses blade template :

Blade is a default template engine of laravel.It is simple yet it has all power tools you need.To read more about blade template ,click here.

Create a file resources/views/anvar.blade.php

<!DOCTYPE html>
 <link href=“” rel=“stylesheet” type=“text/css”>
 html, body {
 height: 100%;
 body {
 margin: 0;
 padding: 0;
 width: 100%;
 display: table;
 font-weight: 100;
 font-family: ‘Lato’;
 .container {
 text-align: center;
 display: table-cell;
 vertical-align: middle;
 .content {
 text-align: center;
 display: inline-block;
 .title {
 font-size: 96px;
 <div class=“container”>
 <div class=“content”>
 <div class=“title”>AlphansoTech Step By Step Laravel Guide</div>


Replace code in app/Http/route.php

Route::get('/alphansotech', function () {
    return view('alphansotech');

I hope you will find this post very useful regarding Laravel beginner guide . Let me know any questions if you have in comment regarding Laravel. I will reply you ASAP.