- How do I install spatie/laravel-blade-comments for Laravel Blade debugging?
- Run `composer require spatie/laravel-blade-comments --dev` to install it as a development dependency. The package auto-registers middleware and precompiler, so no additional steps are needed unless you want to customize exclusions or add commenters. Publish the config with `php artisan vendor:publish --tag=blade-comments-config` if required.
- Will this package slow down my Laravel application in production?
- No, the package is disabled by default when `APP_DEBUG=false`. It only injects debug comments during development, and even then, the performance impact is negligible. Precompilation adds minimal overhead, but it’s designed to be lightweight.
- Does spatie/laravel-blade-comments support Livewire components?
- Yes, the package explicitly supports Livewire components (v3/v4) with dedicated commenters. If you’re using an older version of Livewire, you may need to manually adjust the regex patterns or disable the LivewireComponentCommenter via config.
- Can I exclude certain Blade views from showing debug comments?
- Absolutely. The package includes a config file where you can define exclusions, such as CSS/JS partials or other views you don’t need to debug. Use the `excludedViews` array in the config to blacklist specific paths or patterns.
- What Laravel versions does spatie/laravel-blade-comments support?
- The package is actively maintained for Laravel 11–13 and has backward compatibility for Laravel 9–10. It leverages Laravel’s Blade AST parser (since v2.0), ensuring reliability across modern versions. Check the [GitHub repo](https://github.com/spatie/laravel-blade-comments) for version-specific notes.
- How do debug comments appear in the browser? Can I customize them?
- Debug comments wrap each rendered Blade view/component with HTML comments like `<!-- Blade: front.pages.docs.partials.breadcrumbs -->`. At the top of the document, you’ll also see request and view metadata. You can extend or customize comments by implementing the `BladeCommenter` or `RequestCommenter` interfaces.
- Are there alternatives to spatie/laravel-blade-comments for Blade debugging?
- Yes, alternatives include Laravel Debugbar (for broader debugging) or IDE plugins like PHPStorm’s Blade support. However, this package is specialized for visual Blade debugging in DevTools, offering real-time HTML-level traceability without cluttering your IDE.
- Will debug comments accidentally leak into production if APP_DEBUG is misconfigured?
- No, the package respects Laravel’s `APP_DEBUG` setting. Debug comments are only injected when `APP_DEBUG=true`. To prevent accidental leaks, ensure your CI/CD pipeline enforces `APP_DEBUG=false` in staging and production environments.
- Does this package work with custom Blade directives or macros?
- The package primarily targets standard Blade directives (`@include`, `@section`, `@component`) and Livewire components. Custom Blade macros or directives may not be automatically wrapped. For full coverage, you might need to extend the `BladeCommenter` or adjust the AST parsing logic.
- How can I test spatie/laravel-blade-comments in my Laravel project?
- Enable debug mode (`APP_DEBUG=true`) and inspect the rendered HTML in your browser’s DevTools. Verify that comments appear around Blade views and components. Test edge cases like nested includes or excluded views to ensure the package behaves as expected in your workflow.