Early Access Program Features Releases

Blade Template Engine Support in PhpStorm 8 EAP

blade_laravel_logoBeginning with PhpStorm 8 EAP 138.1505, the IDE provides complete support for Laravel’s Blade template engine.

Support for Blade templates includes highlighting, completion, navigation, find usages, inspections, folding, custom directives, and more.

In this blog post we’ll overview all the Blade-related features.

Support for Blade templates is enabled by default for *.blade.php files, additional file types can be configured in Settings | File Types | Blade.

The first benefit to take advantage of is highlighting of Blade syntax in template files:

blade_tutorial_1

Code completion for Blade includes completion for all directives (including custom directives defined in Settings / Preferences | PHP | Blade; more details below in this blog post):

blade_tutorial_2

Braces are completed as well: blade_tutorial_3

If @for or @foreach directives are used, variable introduction will be offered with autocomplete inside the construct:

blade_tutorial_5

Sections defined with a @section directive can be easily collapsed and expanded (block between @section and closing directive is affected by this action):

blade_tutorial_4

To make sure that a section opened with a @section directive is closed with one of the corresponding directives, there is an inspection checking that the section is closed:

blade_tutorial_6

Blade-specific navigation features include links to templates in @extends and @include directives (use Ctrl+Click / Cmd-Click or Go To Declaration with Ctrl+B / Cmd-B):

blade_tutorial_7

Find usages for Blade templates is supported as well: just invoke it on the file name or a symbol in the code (from the context menu or with Alt+F7) to see all the templates usages across your codebase. Note that it currently works only inside other templates, not from views.

blade_tutorial_8

And finally, if you would like to customize pre-defined Blade directives, or maybe define your own custom directives for Blade templates, you can easily do so in Settings / Preferences | PHP | Blade:

blade_tutorial_9

Feel free to comment on this blog post or write a message in our forums, and please report all the bugs and feature requests to the issue tracker. Thanks!

Develop with pleasure!
-JetBrains PhpStorm Team

image description