You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I also tried with older versions of Laravel (8 & 9) and got the same issue.
Steps To Reproduce
Create a blade template with a single line @php directive and a block of raw PHP using the @php ... @endphp syntax
Add a route that renders the blade template
Open the URL in the browser
The text was updated successfully, but these errors were encountered:
marcbelletre
changed the title
Single @php Blade directive does not work
Single @php Blade directive does not work correctly when followed by a @endphp tag
Aug 3, 2023
Ok but I think there should be a warning about this in the docs if this is a known issue. I struggled for a while because I couldn't see what was wrong in my code before noticing it was coming from a bug in Laravel itself.
I encountered this with roots/sage which is a package that makes a bridge between Wordpress and Laravel.
The default templates are using the following syntax:
Because of this bug it is impossible to use any raw PHP tags inside the loop which is quite a problem. The only workaround is to replace the default @php(the_post()) call to @php the_post() @endphp
Laravel Version
10.17.1
PHP Version
8.2.7
Database Driver & Version
No response
Description
The documentation states that we can use a single
@php
directive like this:It works fine until there is another block of raw PHP that uses the full syntax after.
In the ouput file the PHP end tag is missing:
I also tried with older versions of Laravel (8 & 9) and got the same issue.
Steps To Reproduce
@php
directive and a block of raw PHP using the@php ... @endphp
syntaxThe text was updated successfully, but these errors were encountered: