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:
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):
If @for or @foreach directives are used, variable introduction will be offered with autocomplete inside the construct:
Sections defined with a @section directive can be easily collapsed and expanded (block between @section and closing directive is affected by this action):
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-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):
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.
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:
Develop with pleasure!
-JetBrains PhpStorm Team