Simple Blade Template Laravel

User
use simple blade template in laravel 12
Assistant
In Laravel 12, using a simple Blade template is almost the same as previous versions. Here’s a basic step-by-step example to create and render a simple Blade template:

### ✅ 1. **Create Route**
In your `routes/web.php` file:

use IlluminateSupportFacadesRoute;

Route::get('/', function () {
    return view('welcome'); // or 'home' if you're creating a new view
});

### ✅ 2. **Create Blade View**
Create a new Blade file in `resources/views/`.

Example: `resources/views/welcome.blade.php`

<!DOCTYPE html>
<html>
<head>
    <title>Welcome Page</title>
</head>
<body>
    <h1>Hello from Laravel 12 Blade!</h1>
</body>
</html>

You can also pass data to this view like:

Route::get('/', function () {
    return view('welcome', ['name' => 'Neeraj']);
});

Then in the Blade view:

<h1>Hello, {{ $name }}!</h1>

### ✅ 3. **Use Blade Layouts (Optional but Common)**
If you want to use layout:

#### `resources/views/layouts/app.blade.php`

<!DOCTYPE html>
<html>
<head>
    <title>@yield('title')</title>
</head>
<body>
    <div class="container">
        @yield('content')
    </div>
</body>
</html>

#### `resources/views/home.blade.php`

@extends('layouts.app')

@section('title', 'Home Page')

@section('content')
    <h1>Welcome to Home Page</h1>
@endsection

And route:

Route::get('/home', fn() => view('home'));

Let me know if you want to include Vue, Inertia, or Tailwind with this setup too.

User
install laravel 12 default authication login/register using php blade
Assistant
To install **Laravel 12** with **default authentication using Blade (not Inertia or Vue)**, follow these updated steps. Laravel now uses **Laravel Breeze** for minimal starter kits, and it supports Blade as a frontend option.

## ✅ Step-by-Step: Laravel 12 with Blade Auth (Login/Register)

### 1. **Install Laravel 12**

composer create-project laravel/laravel:^12 laravel-blade-auth
cd laravel-blade-auth

### 2. **Install Laravel Breeze (Blade Version)**

composer require laravel/breeze --dev

Then install **Blade scaffolding**:

php artisan breeze:install blade

### 3. **Run Migrations**

First, set up your database in `.env`, then:

php artisan migrate

### 4. **Install Dependencies and Build Assets**

npm install && npm run build

If you're using **Yarn** instead:

yarn && yarn build

### 5. **Serve the Application**

php artisan serve

Now visit `http://localhost:8000` – You’ll see the Laravel welcome page with **Login** and **Register** links already set up.

## 🧪 What’s Included

This will generate:

– Blade views for login, register, password reset, email verification.
– Auth controllers and routes in `routes/web.php`.
– Middleware-protected dashboard page.

## 🔐 Access Auth Pages

– `/login`
– `/register`
– `/dashboard` (after login)

Let me know if you want to use Bootstrap or Tailwind in the Blade views, or if you want to customize the auth flow.

Leave a Comment

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