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):
Build vs. Buy:
Use Cases:
@include/@component calls.LivewireComponentCommenter).Non-Functional:
--dev), no runtime overhead in production.Adopt if:
APP_DEBUG=true).@include hierarchies.Look Elsewhere if:
config['enable'] or remove --dev dependency).BladeCommenter interface).Alternatives:
<!-- file: resources/views/... --> manually (higher maintenance)."This is a 10-minute debugging superpower for our frontend team. By auto-tagging Blade templates in the HTML output, developers can instantly see which file renders any part of the page—cutting debugging time by 30% during UI iterations. It’s like Google Maps for our Blade templates: no setup, no cost in production, and it works out-of-the-box with Laravel. Teams like Spatie (creators of this package) use it daily to ship features faster."
ROI:
"This package solves a classic Laravel pain point: debugging Blade templates without context. It injects HTML comments around every
@include,@component, and@section, so you can inspect any element in DevTools and instantly see its source file. For example:<!-- /resources/views/partials/breadcrumbs.blade.php --> <nav>...</nav> <!-- /resources/views/partials/breadcrumbs.blade.php -->Key Benefits:
- Works with Livewire/Alpine: Supports component boundaries (v2.0+).
- Exclusion Lists: Skip comments for static partials (e.g., CSS/JS includes) via config.
- Extensible: Add custom commenters for your team’s metadata (e.g.,
@authortags).- Zero Friction: Enabled by default in
APP_DEBUGmode; no manual setup.How to Adopt:
composer require spatie/laravel-blade-comments --devThat’s it. Test in staging first—comments are dev-only and configurable via
config/blade-comments.php."
Tech Deep Dive:
How can I help you explore Laravel packages today?