How to fix @php tab completion?
When in a blade file for Laravel, if I type @php and hit tab or enter it turns it into @php() which is invalid and just throws errors. The correct syntax is
@php
@endphp
How do I stop @php from completing to @php()?
Please sign in to leave a comment.
Hi there,
IDE version?
One possible way that comes into my mind is creating a custom Live Template that will expand into desired code.
If Live Template abbreviation matches some other tag/entity it should be displayed on top (have priority). Or you can always switch into "list live templates only" mode (
Code | Insert Live Template...).>The correct syntax is @php ... @endphp
"@php(expression)" is also supported (at very least it was 1 month ago).
I'm on version 2017.2.4.
If I do
@php(
"insert any php code here"
)
my Laravel 5.2, 5.3 and 5.4 installs all throw an error about an unexpected (.
Thanks for the custom live template idea though, that seems like it's working well now!
@php(
"insert any php code here"
)
Not like that -- it has to be single-liner / simple expression. If you need multi-line stuff -- you have to use @php and @endphp
Hello,
@php() is the same as @php @endphp and same as <?php ?> so there should be no errors.
You just write your PHP code within the braces and it wraps it just as standard PHP tags or as @php @endphp.
What Laravel version do you use? What exact error comes up there?