Skip to content

Fix PHP tags in strings breaking Volt template rendering - #158

Closed
calebporzio wants to merge 1 commit into
mainfrom
codex/php-tags-in-strings
Closed

calebporzio wants to merge 1 commit into
mainfrom
codex/php-tags-in-strings

Conversation

@calebporzio

Copy link
Copy Markdown
Contributor

Literal <?php or ?> text in Volt state can break a valid component's rendering. For example, a component with one root and a title containing ?> currently raises MultipleRootElementsDetectedException on Livewire 4 because template extraction mistakes the string for the end of its PHP block.

Use PHP tokens to identify real PHP boundaries. Preserve the newline included in closing-tag tokens and leave short echo tags intact. Add regression coverage for the reported strings, comments/multiline strings, short echo tags, and rendering through a Livewire update.

Fixes #126. This follows the reporter's suggestion to use PHP's tokenizer.

Verified the failure before the fix on Volt 1.11.2 / Livewire 4.4.5 / Laravel 13.31.0. In a real Chrome browser, the same page now returns 200, displays the literal text correctly, and updates successfully without JavaScript exceptions.

Validation: all 96 unit tests pass, the new functional regression passes, PHPStan reports no errors, and Pint / git diff --check pass.

@calebporzio
calebporzio deleted the codex/php-tags-in-strings branch September 15, 2026 14:38
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.

PHP tags inside strings cause incorrect rendering of template

1 participant