Inject HTML comments and attributes into compiled Blade templates to expose view file paths and source line numbers. Useful for debugging, IDE integration (e.g. Wisra), and AI/LLM-assisted development.
Install via Composer:
composer require bardh78/laravel-wisraThe package auto-discovers its service provider. No additional setup required.
Publish the config file to customize behavior:
php artisan vendor:publish --tag=configOr publish only this package's config:
php artisan vendor:publish --provider="Bardh78\LaravelWisra\LaravelWisraServiceProvider"Environment variables:
| Variable | Default | Description |
|---|---|---|
LARAVEL_WISRA_ENABLED |
true |
Enable or disable the instrumentation |
LARAVEL_WISRA_LOCAL_ONLY |
true |
Only run in the local environment |
Note: After enabling or disabling Wisra, clear the compiled view cache so changes take effect:
php artisan view:clear
- View path comments — Wraps each compiled view with
<!-- [view] /path/to/view.blade.php -->and<!-- [/view] --> - Line annotations — Adds
wisra-start-lineandwisra-end-lineattributes to HTML elements for source mapping - Translation comments — Wraps
__()andtrans()echoes with<!-- [laravel-translation] /path/to/lang/file.php -->for easier translation debugging
When AI coding assistants (Cursor, Copilot, Claude, etc.) work with your Laravel app, they often need to:
- Inspect rendered output — Via browser tools, DOM snapshots, or page source
- Map HTML back to source — Find which Blade file and line produced a given element
- Suggest precise edits — Know exactly where to change code
Without Laravel Wisra: The assistant sees raw HTML with no trace to the Blade source. It must guess files, search the codebase, or rely on structure alone.
With Laravel Wisra: The rendered HTML includes:
- Exact file paths in comments, so the assistant knows which view file to edit
- Line numbers on elements via
wisra-start-lineandwisra-end-line, so it can target the correct line - Translation file paths for
__()calls, so it can update the right lang file
Rendered HTML with Wisra:
<!-- [view] /project/resources/views/welcome.blade.php -->
<div class="hero" wisra-start-line="5" wisra-end-line="12">
<!-- [laravel-translation] /project/lang/en/welcome.php -->
<h1>Welcome to our app</h1>
<!-- [/laravel-translation] -->
</div>
<!-- [/view] /project/resources/views/welcome.blade.php -->An LLM can now:
- Open
resources/views/welcome.blade.phpand edit around lines 5–12 - Open
lang/en/welcome.phpto change the translation for the heading - Avoid searching or guessing which files to modify
- Enable in local/dev — Keep
local_onlytrue so production HTML stays clean - Use with browser MCP tools — When the assistant inspects the page, it gets file/line hints
- Combine with Cursor rules — Mention that view comments are present so the assistant knows to use them
- PHP 8.2+
- Laravel 10.x, 11.x, or 12.x
MIT