Skip to content
PhpStorm Live Templates for Craft CMS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

PhpStorm Live Templates for Craft CMS

Twig and PHP PhpStorm Live Templates for Craft CMS 3.

The Craft CMS Live Templates include various snippets for Craft-specific Twig tags and some other common use cases. Best when paired with Twig - Extended - a more extensive library of PhpStorm Live Templates for Twig.

Craft CMS - Twig

Craft Twig Tags (via tab trigger)

// Examples
asset                    craft.assets.first()
assets                   craft.assets loop
categories               craft.categories loop
entries                  craft.entries loop
feed                     craft.feeds.getFeedItems loop
matrix, matrixif         Basic Matrix field loop using if statements
matrixifelse             Basic Matrix field loop using if/elseif
matrixswitch             Basic Matrix field loop using switch
paginate                 Outputs example of pagination and prev/next links
tags                     craft.tags loop
users                    craft.users loop

// Output Helpers
cache                    {% cache %}...{% endcache %}
csrf                     {{ csrfInput() }}
children                 {% children %}
exit                     {% exit 404 %}
ifchildren               {% ifchildren %}...{% endifchildren %}
hook                     {% hook "$NAME$" %}
nav                      {% nav item in items %}...{% endnav %}
redirect                 {% redirect 'login' %}
redirectinput            {{ redirectInput($URL$) }}
requirelogin             {% requireLogin %}
requirepermission        {% requirePermission "spendTheNight" %}
switch                   {% switch variable %}...{% endswitch %}

css                      {% css %}...{% endcss %}
js                       {% js %}...{% endjs %}
registercssfile          {% do view.registerCssFile("css/style.css") %}
registerjsfile           {% do view.registerJsFile("js/script.js") %}

header                   {% header "string" %}
beginBody                {{ beginBody() }}
endbody                  {{ endBody() }}
head                     {{ head() }}

// Closing tags
case                     {% case "value" %}
endcache                 {% endcache %}
endifchildren            {% endifchildren %}
endcss                   {% endcss %}
endjs                    {% endjs %}
endnav                   {% endnav %}

app            [CURSOR]
config         [CURSOR]

getparam       "name")
getbodyparam   "name")
getqueryparam  "name")

getlocalebyid  $ID$)

Craft Twig Functions (via tab trigger)

alias                    alias("@baseUrl/images/image.png")
ceil                     ceil()
classname                className(object)
clone                    clone(object)
floor                    floor()
getenv                   getenv('name')
max                      max()
min                      min()
round                    round()
shuffle                  shuffle()
svg                      svg('path')
url, urla                url('path'), url('path', params, 'https', false)
siteurl, siteurla        siteUrl('path'), siteUrl('path', params, 'https', 1)

Craft CMS - PHP

Migrations (via tab trigger)

migrate                  A basic migration class

Debugging (via tab trigger)

dd                       Craft::dd("Dump & Die");


  1. Go to PhpStorm Preferences | Tools | Settings Repository
  2. Add Read-only Source
  3. Restart PhpStorm

Visit Preferences->Editor->Live Templates and ensure that the Craft CMS - Twig and Craft CMS - PHP Live Templates are enabled, as desired.

  • Craft CMS - Twig.xml
  • Craft CMS - PHP.xml

Maintenance & Contributions

If you'd like to contribute to the Craft CMS Live Templates, please consider submitting a pull request, reporting an issue, providing examples of how you would like to see the behavior of the Live Templates improved, or just sending your thoughts.


You can’t perform that action at this time.