Vscode-intelephense: Support for "Laravel Blade" language mode

Created on 27 Apr 2018  路  12Comments  路  Source: bmewburn/vscode-intelephense

It would be nice to be able to activate intelephense for other language modes than "php", especially for laravels .blade.php template files, with the "Laravel Blade" language mode selected: https://github.com/onecentlin/laravel-blade-snippets-vscode#blade-syntax-hightlight

enhancement

Most helpful comment

Just tried this plugin for the first time, and was able to leverage a lot of it in blade files by associating blade files with php in my settings.

"files.associations": {
  "*.blade.php": "php"
},

Unfortunately, this causes me to lose all the blade specific syntax highlighting I had with the laravel-blade, which actually configures a 'blade' language. If these two plugins could work together that'd be perfect.

All 12 comments

Can you mix php and blade syntax? If not then I dont think this extension would be useful. HTML/CSS/JS suggestions come from the HTML language server. This extension just forwards requests on in this scenario.

The only thing that keeps me from using VSCode full time is intellisense in blade.php files. In blade you can do this

@php
  echo 'some_stuff and ' . $some_var;
@endphp

Also

{{ a_function_which_returns_something() ? 'this' : 'that' }}

So intellisense inside blade files is essential. (btw I'm using blade syntax with Wordpress and Woocommerce too and its a total nightmare, countless business logic inside the views and ends up in a mixed hell)

Thanks for your awesome work!

@hambos22 What IDE are you using that supports this natively?

@bmewburn In blade templates you can mix php, blade syntax and html too

@7twin PHPStorm

Just tried this plugin for the first time, and was able to leverage a lot of it in blade files by associating blade files with php in my settings.

"files.associations": {
  "*.blade.php": "php"
},

Unfortunately, this causes me to lose all the blade specific syntax highlighting I had with the laravel-blade, which actually configures a 'blade' language. If these two plugins could work together that'd be perfect.

Happy to see this being added as an enhancement, it's a shame we can't currently use this in blade files because it's the best php lang sever, no other comes close.

Great work @bmewburn

Embed var

<div>
{{$var}}
</div>
<div>
{{$var + $var2}}
</div>

Embed method call

<div>
{{$obj->method() + $obj->method("argument, could be var")}}
</div>

Condition

@if (true)
<div></div>
@endif
@if ($obj->method())
<div></div>
@endif

...

Is this feature avilable now? I've tried to make them work with no luck. And there is not much about this topic in the internet as well.

There's a similar issue with JavaScript in blade templates that I'm currently puzzling over the best approach to solving. VSCode probably needs to add support for multiple languages per file extension, but I'm not sure how feasible this is. The blade extension probably needs to support all those possibilities too, but given a blade template could be used on any language, that feels like something outside of its responsibility too.

Can you mix php and blade syntax? If

@bmewburn yes you can. I usually mix a lot of PHP in the blade file, however I cannot [F12] over the class even if it's inside the tags to go to the class definition

image

it would be nice to have this feature :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muuvmuuv picture muuvmuuv  路  4Comments

umpirsky picture umpirsky  路  4Comments

ghnp5 picture ghnp5  路  3Comments

usrnm-nk picture usrnm-nk  路  3Comments

ottopic picture ottopic  路  3Comments