Skip to content

Fix BlazeRuntime injection for wrapped engines (Sentry, Flare)#102

Merged
ganyicz merged 3 commits intomainfrom
filip/fix-sentry-and-statamic
Mar 1, 2026
Merged

Fix BlazeRuntime injection for wrapped engines (Sentry, Flare)#102
ganyicz merged 3 commits intomainfrom
filip/fix-sentry-and-statamic

Conversation

@ganyicz
Copy link
Copy Markdown
Collaborator

@ganyicz ganyicz commented Mar 1, 2026

The scenario

  • Using Blaze alongside packages that wrap the Blade engine (e.g., Sentry).
  • Using Blaze alongside packages that register non-Blade view engines (e.g., Statamic Antlers).

The problem

Previously we used:

View::share(), which injected __blaze into every view, causing a serialization issue in Statamic (#83).

View::composer('*') with an instanceof CompilerEngine check, which fixed that, but broke Sentry (#89) — which decorates the Blade engine without extending CompilerEngine, failing the check and preventing __blaze from being injected.

The solution

Replace the engine class check with a file path check:

if (str_ends_with($view->getPath(), '.blade.php')) {

The file extension is invariant across engine wrapping and decoration:

  • Blade views: .blade.php — matches
  • Blade::render() string templates: written to {hash}.blade.php — matches
  • PHP engine views: .php — no match
  • Antlers views: .antlers.html — no match

Added integration tests for both the Sentry and Statamic scenarios.

Fixes #93

@ganyicz ganyicz merged commit 581ee7f into main Mar 1, 2026
6 checks passed
@ganyicz ganyicz deleted the filip/fix-sentry-and-statamic branch March 1, 2026 21:11
@ganyicz ganyicz changed the title Fix BlazeRuntime injection for wrapped engines Fix BlazeRuntime injection for wrapped engines (Sentry, Flare) Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v1.0.3 breaks when Sentry (or other packages) wrap the view engine

1 participant