Laravel Basics

Install Composer

Install WAMP

c:\wamp64\www>composer create-project laravel/laravel helloworld

Views (C:\wamp64\www\helloworld\resources\views)

  • C:\wamp64\www\helloworld\resources\views\hi.blade.php

Routes (C:\wamp64\www\helloworld\routes)

C:\wamp64\www\helloworld\routes\web.php

Route::get(‘hii’, function () {
return view(‘hi’);
});


Create a new template file in a new subfolder views\layouts\app.blade.php

<html>
<head>
<title>App Name – @yield(‘title’)</title>
</head>
<body>
@section(‘sidebar’)
This is the master sidebar.
@show

<div class=”container”>
@yield(‘content’)
</div>
</body>
</html>


Create  a new Controller as Http\Controllers\MainController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class MainController extends Controller
{
/**
* Show the profile for the given user.
*
* @param int $id
* @return View
*/
public function show()
{
return view(‘layouts.app’);
}
}


Create the route

Route::get(‘start’, ‘MainController@show’);


Test by pointing location to http://localhost/helloworld/public/start

It will call the MainController.
MainController will load the view


 

Add a Comment

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