Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jhargett's avatar

Surround with Blade Directive in PHP Storm

I'm also using PHPStorm. Why doesn't this show up in my Live Template options when I use CTRL + ALT + T? I only get surround with tag. I installed Laravel plugin, which I'd hoped would add this. Also, do I need the Laravel plugin?

0 likes
7 replies
jhargett's avatar

Nevermind, I'm writing my own user-defined PHPStorm Live Template.

jhargett's avatar
jhargett
OP
Best Answer
Level 2

If anyone else wants to do this, add the following user-defined live template

@$TAG$ () $SELECTION$ @end$TAG$

4 likes
ORobertson's avatar

As an addition to this. You can call the abbreviation anything you want (I called it 'B' like Jeffrey has). If you then select the piece of code you want to surround with the blade directive press: Cmd + Option + T (default on Mac), you should now see the template you made, press the abbreviation key you gave it and voila.

1 like
thesivak's avatar

Where exactly do you setup user-defined template?

jhargett's avatar

I'm on windows, File->Settings then expand Editor->Live Template, click the plus sign in the top right corner to make a new one.

2 likes
agileadam's avatar

I've done something similar.

Step 1: Open Settings > Editor > Live Templates

Step 2: Add new live template (I put mine in a custom _Laravel group)

Abbreviation: @

Description: Surround with Blade Directive

Template text:

@$TAG$
    $SELECTION$
@end$TAG$

Applicable for: HTML and PHP

7 likes
Teriz's avatar

@agileadam For me, after placing all the inputs, there was a warning saying No applicable contexts. There's a Define button bellow it. I then checked HTML, and PHP.

Please or to participate in this conversation.