I'm working in WebStorm (PhpStorm) on a .php
file, and I want to quickly insert the standard HTML5 boilerplate (the <!DOCTYPE html>…</html>
structure).
In an .html
file, I can type !
and press Tab
to get the boilerplate via Emmet. However, in a .php
file, it doesn’t seem to work — even if I place my cursor outside the <?php ?>
tags.
Here’s an example of my file:
<!-- I want the HTML5 boilerplate inserted here -->
<?php
echo" i like pizza";
echo "<br>";
echo "i love pizza";
echo "<br>";
//this is a comment
/* this is
a multiline comment
*/
?>
How can I configure PhpStorm so I can type an abbreviation (e.g., !html + Tab
) and insert the full HTML5 boilerplate inside a .php file without breaking PHP execution?
I found the answer in documentation , You can solve this by adding a custom Live Template in Phpstorm.
Go to Settings → Editor → Live Templates, click + to make a new one, give it an abbreviation (like html5
), paste your HTML5 boilerplate in the template text, and under Applicable in, tick PHP
.
Now, in a .php
file (outside your PHP tags), just type your abbreviation and hit Tab — you’ll get the full boilerplate instantly.