What is Blade?
Blade is Laravel's powerful templating engine. It lets you write clean, readable templates without losing the flexibility of plain PHP. Think of it as PHP templates with superpowers.
Every Blade file compiles down to plain PHP, so there's zero performance overhead. You get the convenience of a templating engine with the raw speed of PHP.
Echoing Data
The double curly braces syntax is Blade's way of echoing data. It's clean, safe, and automatically escapes HTML to prevent XSS attacks.
<h1>Welcome, {{ $user->name }}</h1>
<p>You have {{ $notifications->count() }} new notifications.</p>
If you need to echo raw, unescaped HTML, use the @ symbol:
{!! $rawHtml !!}
Try it Yourself โ
Blade vs Raw PHP
Here's a quick comparison. The same template written in raw PHP and in Blade:
<?php if ($active): ?>
<p>You are active.</p>
<?php else: ?>
<p>You are inactive.</p>
<?php endif; ?>
Now look at the Blade version:
@if ($active)
<p>You are active.</p>
@else
<p>You are inactive.</p>
@endif
Blade is shorter, cleaner, and much easier to read. That's the whole point.
Raw Output with @verbatim
Sometimes you want to display Blade syntax literally without it being parsed. Maybe you're writing documentation or showing code examples. That's what @verbatim is for.
@verbatim
<div class="alert">
Welcome, {{ name }}!
</div>
@endverbatim
Everything inside @verbatim is treated as plain text. The curly braces won't be interpreted as Blade expressions.
Why Blade is Fast
Blade templates are compiled to plain PHP and cached. When a request hits your application, Blade doesn't parse templates on the fly โ it runs pre-compiled PHP code. The first request compiles the template, and every request after that uses the cached version.
This means Blade adds virtually zero overhead compared to writing plain PHP. You get the developer experience of a templating engine with the performance of raw PHP. Best of both worlds.