spatie/laravel-blade-comments
Adds HTML debug comments around every rendered Blade view/component so you can see exactly which template produced each part of the page in your browser dev tools. Also includes request and top-level view info at the top of the document.
APP_DEBUG=false (configurable). Runtime overhead is negligible for debug environments.@stack/@yield heavily or include raw HTML strings.'exclude' => [...]).display: none in production-like staging).{{ dd() }} or IDE breakpoints?@stack/@yield patterns that might generate ambiguous comments.APP_DEBUG=true in a staging environment for testing.composer require spatie/laravel-blade-comments
php artisan vendor:publish --provider="Spatie\BladeComments\BladeCommentsServiceProvider"
config/blade-comments.php (e.g., exclude layouts.app, add CSS classes for styling).APP_DEBUG=false to confirm comments are stripped.@verbatim, @once), but test with custom directives.View::render() evolves).<!-- /resources/views/components/header.blade.php -->).APP_DEBUG=false./debug/comments) for dynamic control.| Scenario | Impact | Mitigation |
|---|---|---|
| Comments in production | User-facing debug artifacts | Enforce APP_DEBUG=false in env. |
| Nested component chaos | Unreadable devtools hierarchy | Exclude deep-nested components. |
| Sanitizer conflicts | Comments stripped as "malicious" | Whitelist comment patterns in Purifier. |
| CI/CD false positives | Build failures (e.g., HTML lint) | Add comment exclusions to tests. |
<!-- to locate views.How can I help you explore Laravel packages today?