spatie/laravel-blade-comments
Adds HTML debug comments around every rendered Blade view/component so you can see exactly which template produced each piece of output in browser dev tools. Also includes top-level request and view info at the top of the document.
Debugging & Developer Experience (DX):
@include, @section, Livewire components).APP_DEBUG=true or for specific user roles).Build vs. Buy:
Use Cases:
Tooling Integration:
RequestCommenter/BladeCommenter).Adopt if:
@include, @stack, or Livewire components) where visual cues improve productivity.APP_DEBUG by default).Look elsewhere if:
dd() in controllers) over visual annotations.config for live sites).excludes config.Alternatives:
Log::debug() in Blade files (less visual, harder to correlate with HTML).ob_start() to wrap HTML in comments (more overhead)."This package adds HTML comments to every Blade template in our Laravel app, so developers can instantly see which .blade.php file rendered any part of the page—just by inspecting the source in DevTools. For example, if a bug appears in the checkout flow, we’ll know in seconds whether it’s in views/cart/checkout.blade.php or a nested component. It’s like Google Maps for our templates, reducing debugging time by 30–50% during critical fixes. The cost? A negligible 1–5KB overhead in debug mode, and it’s free (MIT license)."
ROI:
*"Problem: Debugging Blade templates is a pain—you see HTML in the browser but not which .blade.php file generated it. You end up grep-ing files, adding {{ dd() }}, or guessing.
Solution: This package automatically wraps Blade output in HTML comments, so you can:
<!-- /resources/views/partials/header.blade.php -->).@include, @section) visually.How it works:
composer require spatie/laravel-blade-comments --dev).config/blade-comments.php (toggled by APP_DEBUG).<!-- /resources/views/layouts/app.blade.php -->
<header>...</header>
<!-- /resources/views/partials/nav.blade.php -->
Why now?
Next steps:
excludes to avoid clutter (e.g., ignore styles.* partials)."*Key Selling Points:
How can I help you explore Laravel packages today?