Describe the bug
In v1.0.3, BlazeServiceProvider::registerBlazeRuntime() checks $view->getEngine() instanceof CompilerEngine before injecting the $__blaze runtime variable. When Sentry Laravel (sentry/sentry-laravel) is installed, it decorates the view engine with Sentry\Laravel\Tracing\ViewEngineDecorator, which is not an instance of CompilerEngine. This causes $__blaze to never be injected, resulting in Undefined variable $__blaze errors on all views that render Blaze-compiled components.
This worked in v1.0.2 where the instanceof guard did not exist (or handled decorated engines).
Component causing the issue
Any anonymous Blade component optimized by Blaze triggers the error. For example:
{{-- resources/views/components/smm-navigation.blade.php --}}
@props(['active-tab' => 'facebook'])
{{-- navigation content --}}
Used in a parent view:
{{-- resources/views/dashboard/social_media_management/index.blade.php --}}
Expected behavior
The $__blaze runtime variable should be injected into all Blade views regardless of whether the view engine is wrapped by a decorator (Sentry, Debugbar, etc.), and Blaze-compiled components should render normally.
Actual behavior
All views that use Blaze-compiled components throw:
ErrorException: Undefined variable $__blaze in storage/framework/views/94bfea3ca184e60b57992ddfe304b22f.php:127
The compiled view references $__blaze->ensureCompiled(...) but the variable is never set because the engine check fails.
Root cause
In BlazeServiceProvider.php:56-65:
View::composer('*', function (\Illuminate\View\View $view) {
if (Blaze::isDisabled() && ! Blaze::isDebugging()) {
return;
}
if ($view->getEngine() instanceof CompilerEngine) { // <-- fails here
$view->with('__blaze', $this->app->make(BlazeRuntime::class));
}
});
$view->getEngine() returns Sentry\Laravel\Tracing\ViewEngineDecorator instead of Illuminate\View\Engines\CompilerEngine, so the instanceof check is false and $__blaze is never injected.
Suggested fix
Unwrap decorated engines before checking, e.g.:
$engine = $view->getEngine();
// Unwrap decorated engines (Sentry, Debugbar, etc.)
while (! $engine instanceof CompilerEngine && method_exists($engine, 'getEngine')) {
$engine = $engine->getEngine();
}
if ($engine instanceof CompilerEngine) {
$view->with('__blaze', $this->app->make(BlazeRuntime::class));
}
Environment
Laravel version: 12.x
PHP version: 8.3
Blaze version: 1.0.3 (works in 1.0.2)
Sentry Laravel: sentry/sentry-laravel (latest)
Additional context
This likely affects any package that decorates the view engine (Sentry, Laravel Debugbar, etc.). The issue is specific to v1.0.3 — pinning to v1.0.2 resolves the problem. Clearing view cache (php artisan view:clear) does not help since the compiled views are regenerated with $__blaze references (Blaze compilation runs fine), but the runtime injection is blocked by the engine check.
Describe the bug
In v1.0.3, BlazeServiceProvider::registerBlazeRuntime() checks $view->getEngine() instanceof CompilerEngine before injecting the $__blaze runtime variable. When Sentry Laravel (sentry/sentry-laravel) is installed, it decorates the view engine with Sentry\Laravel\Tracing\ViewEngineDecorator, which is not an instance of CompilerEngine. This causes $__blaze to never be injected, resulting in Undefined variable $__blaze errors on all views that render Blaze-compiled components.
This worked in v1.0.2 where the instanceof guard did not exist (or handled decorated engines).
Component causing the issue
Any anonymous Blade component optimized by Blaze triggers the error. For example:
{{-- resources/views/components/smm-navigation.blade.php --}}
{{-- navigation content --}} Used in a parent view:@props(['active-tab' => 'facebook'])
{{-- resources/views/dashboard/social_media_management/index.blade.php --}}
Expected behavior
The $__blaze runtime variable should be injected into all Blade views regardless of whether the view engine is wrapped by a decorator (Sentry, Debugbar, etc.), and Blaze-compiled components should render normally.
Actual behavior
All views that use Blaze-compiled components throw:
ErrorException: Undefined variable $__blaze in storage/framework/views/94bfea3ca184e60b57992ddfe304b22f.php:127
The compiled view references $__blaze->ensureCompiled(...) but the variable is never set because the engine check fails.
Root cause
In BlazeServiceProvider.php:56-65:
View::composer('*', function (\Illuminate\View\View $view) {
if (Blaze::isDisabled() && ! Blaze::isDebugging()) {
return;
}
});
$view->getEngine() returns Sentry\Laravel\Tracing\ViewEngineDecorator instead of Illuminate\View\Engines\CompilerEngine, so the instanceof check is false and $__blaze is never injected.
Suggested fix
Unwrap decorated engines before checking, e.g.:
$engine = $view->getEngine();
// Unwrap decorated engines (Sentry, Debugbar, etc.)
while (! $engine instanceof CompilerEngine && method_exists($engine, 'getEngine')) {
$engine = $engine->getEngine();
}
if ($engine instanceof CompilerEngine) {
$view->with('__blaze', $this->app->make(BlazeRuntime::class));
}
Environment
Laravel version: 12.x
PHP version: 8.3
Blaze version: 1.0.3 (works in 1.0.2)
Sentry Laravel: sentry/sentry-laravel (latest)
Additional context
This likely affects any package that decorates the view engine (Sentry, Laravel Debugbar, etc.). The issue is specific to v1.0.3 — pinning to v1.0.2 resolves the problem. Clearing view cache (php artisan view:clear) does not help since the compiled views are regenerated with $__blaze references (Blaze compilation runs fine), but the runtime injection is blocked by the engine check.