- How do I install and enable Blaze in a Laravel 9+ project?
- Run `composer require livewire/blaze:^1.0` to install. Enable it by adding the `@blaze` directive to individual components or calling `Blaze::optimize()->in(resource_path('views/components'))` in your `AppServiceProvider`. Always run `php artisan view:clear` afterward.
- Will Blaze break existing Blade components or Livewire reactivity?
- No, Blaze is a drop-in replacement for anonymous Blade components and works seamlessly with Livewire. It only optimizes components marked with `@blaze` or in optimized directories, leaving the rest untouched. Livewire’s reactivity remains intact.
- What’s the difference between `@blaze`, `@blaze(memo: true)`, and `@blaze(fold: true)`?
- The basic `@blaze` compiles components into optimized PHP functions for faster rendering. `@blaze(memo: true)` caches repeated renders, while `@blaze(fold: true)` pre-renders components into static HTML. Use memoization for dynamic components and folding for static ones.
- Does Blaze support all Blade features, like slots, props, or directives?
- Blaze supports 90%+ of Blade features, including slots, props, and directives like `@class` or `@unless`. However, it doesn’t support class-based components, view composers, or features relying on the `$component` variable. Check the [limitations](https://github.com/livewire/blaze#limitations) for details.
- How do I test if Blaze is working and measure performance gains?
- Use Laravel Debugbar or tools like Tideways/xhprof to profile rendering times before and after enabling Blaze. For example, rendering 25,000 anonymous components drops from ~500ms to ~13ms with Blaze. Test in a staging environment first.
- Can I use Blaze with Livewire Flux UI without extra configuration?
- Yes, if you’re using Flux UI, simply install Blaze via Composer (`composer require livewire/blaze`). Flux UI automatically integrates with Blaze, so no additional setup is needed. This is ideal for Livewire-powered SPAs or dashboards.
- What should I do if Blaze causes errors or regressions in production?
- Start by disabling Blaze for problematic components using `@blaze(false)`. Clear views with `php artisan view:clear` and test incrementally. Use feature flags or environment-based toggles to roll back if needed. Always test in staging first.
- Is Blaze compatible with Laravel 8 or PHP 8.0?
- No, Blaze requires **PHP 8.1+** and **Laravel 9+**. It leverages PHP 8.1’s attributes and performance improvements, so downgrading isn’t supported. Ensure your project meets these requirements before installing.
- How does Blaze affect deployment times or CI/CD pipelines?
- Blaze compiles views during `php artisan view:clear`, which adds a small overhead to deployments. Add `php artisan view:clear` to your deployment scripts. For CI/CD, ensure your pipeline runs this command after code changes to avoid runtime errors.
- Are there alternatives to Blaze for optimizing Laravel Blade performance?
- Alternatives include caching entire views with Laravel’s cache system or using static site generators like Laravel Vapor or Hugo for static content. However, Blaze uniquely targets **anonymous Blade components** with near-zero configuration, offering 91–97% rendering speedups without caching entire pages.