- How do I install Livewire/Blaze in my Laravel project?
- Run `composer require livewire/blaze:^1.0` to install Blaze. No additional Laravel version requirements beyond standard Blade support. Clear your view cache afterward with `php artisan view:clear`.
- Will Blaze work with my existing Livewire or Alpine.js components?
- Yes, Blaze integrates seamlessly with Livewire and Alpine.js, especially Flux UI. It optimizes Blade rendering without touching JavaScript logic. Test edge cases like dynamic attributes or event listeners post-installation.
- Can I use Blaze with class-based components (e.g., `php artisan make:component`)?
- No, Blaze is designed for anonymous Blade components only. Class-based components (stored in `app/View/Components/`) are not supported. Profile your app first to identify anonymous components for optimization.
- What’s the difference between `@blaze`, memoization, and folding?
- `@blaze` alone compiles components into PHP functions for speed. Memoization caches repeated renders (use for static data like icons). Folding pre-renders to static HTML (best for truly static content). Memoization and folding require extra configuration and testing.
- How do I enable Blaze for an entire directory of views?
- Add `Blaze::optimize()->in(resource_path('views/path'))` to your `AppServiceProvider::boot()`. Start with a single directory to test compatibility. Run `php artisan view:clear` afterward. Avoid directories with unsupported Blade features like `@stack` or `@inject`.
- Will Blaze break my app if I enable it globally?
- Blaze maintains near-full Blade feature parity, but some features (e.g., `@stack`, `@section`, `@auth`, `now()`) may fail silently. Test thoroughly in staging first. Use `@blaze` per-component for gradual adoption.
- How do I measure Blaze’s performance impact?
- Use Laravel Debugbar or Telescope to profile Blade rendering times before/after. For large-scale tests, compare GTmetrix or Lighthouse scores. Blaze typically reduces rendering overhead by 91-97% for anonymous components.
- Are there alternatives to Blaze for optimizing Laravel Blade?
- For anonymous components, Blaze is the most targeted solution. Alternatives include caching entire views with `Cache::remember()` or using static site generators (e.g., Laravel Vapor + Blade). However, none match Blaze’s granular, drop-in optimization for Blade.
- How do I handle cache invalidation when using Blaze?
- Always run `php artisan view:clear` after enabling Blaze or updating optimized components. For CI/CD pipelines, automate this step. Memoized or folded components may need manual cache busting if their underlying data changes.
- Can I use Blaze with Laravel’s Inertia.js integration?
- Yes, Blaze works with Inertia.js since it optimizes Blade rendering on the server. Ensure your Inertia pages use anonymous components (not class-based) for full compatibility. Test page hydration times for improvements.