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

This entry was posted in Cool Feature, Early Access Program and tagged , , , , . Bookmark the permalink.
  • Thierry Goettelmann

    Good job guys. Thank you :)

  • Mikhail Krasilnikov

    http://youtrack.jetbrains.com/issue/IDEA-77483 — is almost 3 years old. 180 votes. And still no plans to fix it.

    http://youtrack.jetbrains.com/issue/IDEA-106966
    every time I switch between projects, I curse the one who invented this illogical “shared” and the whole way to manage code style and inspections profiles.

    You are adding more and more new features but ignoring problems in existed ones for years. What do I pay for?!

    • Andriy Bazanov

      I hope you understand that Blade support was done by COMPLETELY DIFFERENT people that have NO relation to those tickets?

    • Liubov Melnikova

      Thanks for the report, we are aware of the problem, we know how to reproduce it. But for now there are no specific dates for a fix.
      As soon as it is fixed, you will receive a notification if you follow the issues on YouTrack.

    • Adrian Grund

      My words. Too much “so-called” features which only help a few users. Where are the features everybody can use? Currently all folders are scanned for intellisense e.g.. There is a feature request to disable intellisense for several folders (which I need to see in phpstorm). That would be killer-features every user would profit. But all this frameworks… I am so disappointed about the absence of new features I can use…. I think it is back to EAP 6 which introduced a real great new feature for everyone-use….

      • Ronald

        You can click on ANY folder and “Mark Directory As” -> Exclude OR can manage that under Settings -> Directories to remove the files inside from being parsed.

        Well remove intellisense *in* a certain folder makes indeed no sense to me. I never ever needed a awesome feature NOT.

  • Pingback: PhpStorm 8 z obsługą blade templates - Laravel.pl

  • Thijs Kaspers

    Great update, thanks alot! I’ve been waiting for this for quite some while and it seems to be working perfectly so far in the EAP version.

    Speaking about it, is there anything on the roadmap for full Laravel framework integration (e.g. Eloquent ORM, Artisan, etc.)? Right now I see that PHPStorm supports Symfony and Yii, but Laravel is becoming more and more popular and it looks like it’s here to stay.

    Thanks again for the Blade support

    • http://espend.de Haehnchen

      Just use Symfony, as i teached you :)
      greets
      Daniel Espendiller

      • Thijs Kaspers

        Hahaha, good one :D! I prefer Laravel though nowadays, the learning curve is alot lower for new developers ;). But I must say Laravel wouldn’t have been here without Symfony, it uses more than 10 Symfony dependencies including Doctrine, Routing etc.

        Both frameworks are great. Have you tried Laravel?

        • http://espend.de Haehnchen

          i was reading the Laravel docs in background, because of symfony2 components, as i saw your comment about it. :)
          Should not be too hard to provide a phpstorm plugin for it, because they have much in common.

  • Pingback: PhpStorm 8 EAP 138.1505 | JetBrains PhpStorm Blog

  • Ian Hiscock

    Thanks for the update.

    Is there anyway to type hint variables within blade files passed in through the View?
    If defined as {{ /** @var Class $o */ }} the hints only apply to that block.
    If defined as the editor gets confused with the @var phpdoc tag.

    (I was hoping to define and type all view parameters in a comment block at the top)

    • Ian Hiscock

      that second example has been tag stripped.. it should show a traditional php block containing the same comment

    • Jonathan Williamson

      Yes, this is exactly what I was hoping for too. (Have you found a work around?)

      When you pass a variable to the view from your controller, I would love Phpstorm to be able to use auto complete when typing inside the view.

      Is there an issue number for this – I couldn’t find it? I don’t want to make a duplicate but if there’s not I’ll add a request.

  • Tommy Bergeron

    That’s awesome, thanks JetBrains! One major bug for me though I cannot open my project at all, files don’t get shown in the navigation, etc. All I get is:

    4:41:24 PM NoClassDefFoundError: com/intellij/openapi/fileEditor/impl/TrailingSpacesStripper

    Any ideas of a workaround? Thanks

    • Tommy Bergeron

      Nevermind! All I had to do is disable the Markdown plugin! Yay!

      • Dele O

        Nice, this worked for me too!

      • Julio

        Works for me! Thanks!

      • http://notrix.lt NoTriX

        Thanks. Worked for me too.

  • Jimmy Puckett

    Thanks! You are missing @forelse/@endforelse. I know that I can manually, but I figured that you want to add it to the application. You can see that it got added with 4.2…

    https://twitter.com/laravelphp/status/487695515673710593

  • Hai Nguyen

    Good jobs guys!

  • Scott Lee

    Anyone else getting the perpetual ‘loading…’ error in the File Browser/Favorites? SS: https://cloudup.com/c6INJ_y2t0q

    • http://www.danielsadek.cz Daniel Šádek

      same way – disable the Markdown plugin

  • Markus Lehtonen

    Code reformating doesn’t seem to do anything for blade files now.

  • Drew Ewing

    Nice work! Looks good.

  • Nadav

    I’m so happy I decided to go with PhpStorm. It’s nice to see you are listening to the customers and actually doing what people ask for in YouTrack.

    Thank you! You are awesome!!!

  • Frank

    YES! Been waiting for so long for this.
    So excited to try it!

  • Patrick

    Blade templating support!? You guys are awesome! Thank you so much. Definitely the biggest feature I was looking forward to.

  • seco

    Blade is ok but what about laravel autocomplete
    Currently there is only one small plugin that does not do it well
    Is there any plans for laravel support
    Thanks in advance

    • Chris

      I have a _ide.helper.php inside my laravel projects that works 90%. I don’t get autocomplete on my facades, but i get it for laravel’s facades. Works for me.

  • Maciej

    Hi,
    I’ve got quick question – how to format (auto indent) html code in .blade.php template file in the PHPStorm EAP.
    Thanks in advance.

    • Maxim Kolmakov

      Unfortunately it’s not possible yet. Please vote for http://youtrack.jetbrains.com/issue/WI-24357

      • Albin

        It seems that support for indenting should have been a top priority. Sad to say blade templates in PHPStorm are useless for now. Waiting for a fix. I disabled Blade support for now.

  • Pingback: PhpStorm 8 released: Blade, Behat, WordPress, Remote PHP interpreters, multiple carets/selections, and more | JetBrains PhpStorm Blog

  • Nic

    YESSSSS! \o///
    FINALLY!!!!!!
    TODAY IS THE MOST HAPPY DAY OF MY LIFE!!!

    THANKS ALOT!!!!!!

  • Pingback: PhpStorm 8 Released - See What's New and Grab a Free License

  • http://anirecs.infinityanime.com/ Façade

    is there any way to manual add support for {!! xyz !!}? Its new in laravel 5 and would be great If I could make it do the same as {{ }}