Originally published on laravel.learnio.dev — part of the Laravel best practices course. View this lesson on the original site.
In this lesson
Build a tiny Laravel app page that uses the full beginner flow: route, controller, Blade view, and passed data.
Project goal
Create a /hello page that shows:
- a greeting message,
- current environment name,
- current date and time.
This gives you one working end-to-end request path.
Step 1: Generate a controller
Run:
php artisan make:controller HelloController
Then edit app/Http/Controllers/HelloController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\View\View;
class HelloController extends Controller
{
public function index(): View
{
return view('hello', [
'message' => 'Hello Laravel',
'environment' => app()->environment(),
'now' => now()->toDateTimeString(),
]);
}
}
Step 2: Add a route
Edit routes/web.php:
use App\Http\Controllers\HelloController;
use Illuminate\Support\Facades\Route;
Route::get('/hello', [HelloController::class, 'index'])->name('hello.index');
Step 3: Create the Blade view
Create resources/views/hello.blade.php:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello Laravel</title>
</head>
<body>
<h1>{{ $message }}</h1>
<p>Environment: {{ $environment }}</p>
<p>Server time: {{ $now }}</p>
</body>
</html>
Step 4: Run and verify
Start the app if needed:
php artisan serve
Open:
http://127.0.0.1:8000/hello
Expected result:
- page renders with "Hello Laravel",
- environment value appears (
localon most dev setups), - time updates on refresh.
What this mini project teaches
flowchart LR
A[Route in web file] --> B[HelloController index method]
B --> C[Blade hello view]
C --> D[HTML in browser]
You now have a repeatable baseline for new pages: route, controller action, view, and data binding.
From Laravel best practices — What is Laravel?