Blade @php now REQUIRES @endphp, when it didn't before? Is this a bug?

In previous themes I was able to write php on a single line like so:

@php(do_the_thing())

But now if I do that, it breaks the page and gives php errors. I have to do it like this:

@php do_the_thing(); @endphp

I’ve done a lot of searching with a couple results, but no real answer… Was this single line feature removed? Is it a bug? Doing it the second way feels so klunky when it’s just a single line of php… I am typing more than if I were to just use regular php.

This was changed in Laravel 5.5, which Sage updated to. It’s a little chunkier, but you’ll need to include both the opening and closing expressions now.

See:

“I am typing more than if I were to just use regular php.” Generally the intent of Blade is that you are not writing PHP in it: Any logic should be handled at the controller level (i.e. with soberwp/controller or Sage’s filters).

1 Like