Skip to content

Instantly share code, notes, and snippets.

@cmuench
Last active July 23, 2018 05:39
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cmuench/acf8de3055213da6a61755e942f7214e to your computer and use it in GitHub Desktop.
Save cmuench/acf8de3055213da6a61755e942f7214e to your computer and use it in GitHub Desktop.
PHPStorm Live Templates for Magento 2 (copy xml content to clipboard and paste it in a template group)
<template name="magento2:__" value="&lt;?php echo __('$SELECTION$'); ?&gt;" description="Translation" toReformat="false" toShortenFQNames="true">
<context>
<option name="HTML" value="true" />
<option name="PHP" value="true" />
</context>
</template>
<template name="magento2:collection" value="class Collection extends AbstractCollection&#10;{&#10; /**&#10; * Initialize resource model&#10; *&#10; * @return void&#10; */&#10; protected function _construct()&#10; {&#10; $this-&gt;_init($model$::class, $resourceModel$::class);&#10; }&#10;}" toReformat="true" toShortenFQNames="true">
<variable name="model" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="resourceModel" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="PHP" value="true" />
<option name="PHP Comment" value="false" />
<option name="PHP String Literal" value="false" />
</context>
</template>
<template name="magento2:console:command" value="&lt;?php&#10;&#10;namespace $namespace$;&#10;&#10;use Symfony\Component\Console\Command\Command;&#10;use Symfony\Component\Console\Input\InputArgument;&#10;use Symfony\Component\Console\Input\InputInterface;&#10;use Symfony\Component\Console\Output\OutputInterface;&#10;&#10;/**&#10; * $description$&#10; */&#10;class $class$Command extends Command&#10;{ &#10; /**&#10; * command name&#10; */&#10; const COMMAND_NAME = '$name$'; &#10;&#10; /**&#10; * {@inheritdoc}&#10; */&#10; protected function configure()&#10; { &#10; $this-&gt;setName(self::COMMAND_NAME)&#10; -&gt;setDescription($description$); &#10;&#10; parent::configure();&#10; }&#10;&#10; /** &#10; * @param InputInterface $input&#10; * @param OutputInterface $output&#10; * @return int Non zero if invalid type, 0 otherwise&#10; */&#10; protected function execute(InputInterface $input, OutputInterface $output)&#10; {&#10; &#10; return 0;&#10; } &#10;}&#10;&#10;" toReformat="true" toShortenFQNames="true">
<variable name="namespace" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="description" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="class" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="PHP" value="true" />
<option name="PHP Comment" value="false" />
<option name="PHP String Literal" value="false" />
</context>
</template>
<template name="magento2:controller:action" value="namespace $namespace$;&#10;&#10;use Magento\Framework\App\Action\Action;&#10;use Magento\Framework\App\ResponseInterface;&#10;&#10;class $action$ extends Action&#10;{&#10; /**&#10; * Dispatch request&#10; *&#10; * @return \Magento\Framework\Controller\\Magento\Framework\Controller\ResultInterface|ResponseInterface&#10; * @throws \Magento\Framework\Exception\\Magento\Framework\Exception\NotFoundException&#10; */&#10; public function execute()&#10; {&#10;&#10; }&#10;}" toReformat="true" toShortenFQNames="true">
<variable name="namespace" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="action" expression="capitalize(String)" defaultValue="Index" alwaysStopAt="true" />
<context>
<option name="PHP" value="true" />
<option name="PHP Comment" value="false" />
<option name="PHP String Literal" value="false" />
</context>
</template>
<template name="magento2:setup:table:column:product-id" value="-&gt;addColumn(&#10; 'product_id',&#10; \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,&#10; null,&#10; ['unsigned' =&gt; true, 'nullable' =&gt; false],&#10; 'Reference to product table'&#10;)&#10;-&gt;addForeignKey(&#10; $setup-&gt;getFkName(&#10; '$table$',&#10; 'product_id',&#10; 'catalog_product_entity',&#10; 'entity_id'&#10; ),&#10; 'product_id',&#10; $setup-&gt;getTable('catalog_product_entity'),&#10; 'entity_id',&#10; \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE&#10;) " toReformat="true" toShortenFQNames="true">
<variable name="table" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="PHP" value="true" />
<option name="PHP Comment" value="false" />
<option name="PHP String Literal" value="false" />
</context>
</template>
<template name="magento2:setup:table:column:store-id" value="-&gt;addColumn(&#10; 'store_id',&#10; \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,&#10; null,&#10; ['unsigned' =&gt; true, 'nullable' =&gt; false, 'default' =&gt; '0'],&#10; 'Store ID'&#10;)&#10;-&gt;addForeignKey(&#10; $installer-&gt;getFkName('$table$', 'store_id', 'store', 'store_id'),&#10; 'store_id',&#10; $installer-&gt;getTable('store'),&#10; 'store_id',&#10; \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE&#10;)" toReformat="true" toShortenFQNames="true">
<variable name="table" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="PHP" value="true" />
<option name="PHP Comment" value="false" />
<option name="PHP String Literal" value="false" />
</context>
</template>
<template name="magento2:setup:table:price" value="-&gt;addColumn(&#10; 'price',&#10; \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL,&#10; '12,4',&#10; ['nullable' =&gt; false, 'default' =&gt; '0.0000'],&#10; 'Price Value'&#10;)" toReformat="true" toShortenFQNames="true">
<context>
<option name="PHP" value="true" />
<option name="PHP Comment" value="false" />
<option name="PHP String Literal" value="false" />
</context>
</template>
<template name="magento2:test:mock:quote" value="$quoteMock = $this-&gt;getMockBuilder(CartInterface::class)-&gt;getMock();" toReformat="true" toShortenFQNames="true">
<context>
<option name="PHP Expression" value="true" />
<option name="PHP Statement" value="true" />
</context>
</template>
<template name="magento2:test:objectManager" value="$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);&#10;$var$ = $objectManagerHelper-&gt;getObject('$class$', []);&#10;/* @var $var$ \$class$ */&#10;" toReformat="true" toShortenFQNames="true">
<variable name="var" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="class" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="PHP" value="true" />
<option name="PHP Comment" value="false" />
<option name="PHP String Literal" value="false" />
</context>
</template>
<template name="magento2:xml:acl" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Acl/etc/acl.xsd&quot;&gt;&#10; &lt;acl&gt;&#10; &lt;resources&gt;&#10; &lt;resource id=&quot;$module$::$resource_name$&quot;&gt;&#10; &lt;/resource&gt;&#10; &lt;/resources&gt;&#10; &lt;/acl&gt;&#10;&lt;/config&gt;&#10; " toReformat="true" toShortenFQNames="true">
<variable name="module" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="resource_name" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:acl:store-config" value="&lt;acl&gt;&#10; &lt;resources&gt;&#10; &lt;resource id=&quot;Magento_Backend::admin&quot;&gt;&#10; &lt;resource id=&quot;Magento_Backend::stores&quot;&gt;&#10; &lt;resource id=&quot;Magento_Backend::stores_settings&quot;&gt;&#10; &lt;resource id=&quot;Magento_Config::config&quot;&gt;&#10; &lt;resource id=&quot;$myid$&quot; title=&quot;$mytitle$&quot; translate=&quot;title&quot; /&gt;&#10; &lt;/resource&gt;&#10; &lt;/resource&gt;&#10; &lt;/resource&gt;&#10; &lt;/resource&gt;&#10; &lt;/resources&gt;&#10;&lt;/acl&gt;" toReformat="true" toShortenFQNames="true">
<variable name="myid" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="mytitle" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:config" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&#10; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Store:etc/config.xsd&quot;&gt;&#10; &lt;default&gt;&#10; &lt;/default&gt;&#10;&lt;/config&gt; " toReformat="false" toShortenFQNames="true">
<context>
<option name="XML" value="true" />
</context>
</template>
<template name="magento2:xml:crontab" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Cron:etc/crontab.xsd&quot;&gt;&#10;&#10; &lt;group id=&quot;default&quot;&gt; &#10; &lt;/group&gt;&#10;&lt;/config&gt;&#10;" toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:di" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager/etc/config.xsd&quot;&gt; &#10;&lt;/config&gt;" toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:di:add-command" value="&lt;type name=&quot;Magento\Framework\Console\CommandList&quot;&gt;&#10; &lt;arguments&gt;&#10; &lt;argument name=&quot;commands&quot; xsi:type=&quot;array&quot;&gt;&#10; &lt;item name=&quot;$name$Command&quot; xsi:type=&quot;object&quot;&gt;$class$&lt;/item&gt; &#10; &lt;/argument&gt;&#10; &lt;/arguments&gt;&#10; &lt;/type&gt;" toReformat="true" toShortenFQNames="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="class" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:di:add-router" value="&lt;type name=&quot;Magento\Framework\App\RouterList&quot;&gt;&#10; &lt;arguments&gt;&#10; &lt;argument name=&quot;routerList&quot; xsi:type=&quot;array&quot;&gt;&#10; &lt;item name=&quot;$name$&quot; xsi:type=&quot;array&quot;&gt;&#10; &lt;item name=&quot;class&quot; xsi:type=&quot;string&quot;&gt;$class$&lt;/item&gt;&#10; &lt;item name=&quot;disable&quot; xsi:type=&quot;boolean&quot;&gt;false&lt;/item&gt;&#10; &lt;item name=&quot;sortOrder&quot; xsi:type=&quot;string&quot;&gt;$order$&lt;/item&gt;&#10; &lt;/item&gt; &#10; &lt;/argument&gt;&#10; &lt;/arguments&gt;&#10;&lt;/type&gt;" description="Registrates a router class" toReformat="true" toShortenFQNames="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="class" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="order" expression="" defaultValue="50" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:di:secure-url" value="&lt;type name=&quot;Magento\Framework\Url\SecurityInfo&quot;&gt;&#10; &lt;arguments&gt;&#10; &lt;argument name=&quot;secureUrlList&quot; xsi:type=&quot;array&quot;&gt;&#10; &lt;item name=&quot;$name$&quot; xsi:type=&quot;string&quot;&gt;/$name$/&lt;/item&gt;&#10; &lt;/argument&gt;&#10; &lt;/arguments&gt;&#10;&lt;/type&gt;" toReformat="true" toShortenFQNames="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:email-templates" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;!--&#10;/**&#10; * Copyright © 2016 Magento. All rights reserved.&#10; * See COPYING.txt for license details.&#10; */&#10;--&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Email:etc/email_templates.xsd&quot;&gt;&#10; $cursor$&#10;&lt;/config&gt;&#10;" toReformat="true" toShortenFQNames="true">
<variable name="cursor" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:events" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Event/etc/events.xsd&quot;&gt;&#10;&lt;/config&gt;" toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:extension-attributes" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Api/etc/extension_attributes.xsd&quot;&gt;&#10; &#10;&lt;/config&gt;&#10;" toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:fieldset" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&#10; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:DataObject/etc/fieldset.xsd&quot;&gt;&#10;&lt;/config&gt;&#10;" toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:indexer" value="&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&#10; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Indexer/etc/indexer.xsd&quot;&gt;&#10;&lt;/config&gt; " toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:layout" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;layout xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View/Layout/etc/layout_generic.xsd&quot;&gt;&#10;&lt;/layout&gt;" toReformat="false" toShortenFQNames="true">
<context>
<option name="XML" value="true" />
</context>
</template>
<template name="magento2:xml:menu" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Backend:etc/menu.xsd&quot;&gt;&#10;&lt;/config&gt; " toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:module" value="&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Module/etc/module.xsd&quot;&gt;&#10; &lt;module name=&quot;$name$&quot; setup_version=&quot;1.0.0&quot;&gt;&#10; &lt;sequence&gt; &#10; &lt;/sequence&gt;&#10; &lt;/module&gt;&#10;&lt;/config&gt;&#10;" toReformat="true" toShortenFQNames="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:page" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;page xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&#10; layout=&quot;2columns-left&quot; &#10; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View/Layout/etc/page_configuration.xsd&quot;&gt;&#10; $cursor$&#10;&lt;/page&gt;" toReformat="true" toShortenFQNames="true">
<variable name="cursor" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:page-types" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;page_types xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View/Layout/etc/page_types.xsd&quot;&gt;&#10;&lt;/page_types&gt;" toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:product-types" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;page xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; layout=&quot;2columns-left&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View/Layout/etc/page_configuration.xsd&quot;&gt;&#10;&lt;/page&gt;" toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:routes" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:App/etc/routes.xsd&quot;&gt;&#10; &lt;router id=&quot;standard&quot;&gt;&#10; &lt;route id=&quot;$id$&quot; frontName=&quot;$frontname$&quot;&gt;&#10; &lt;module name=&quot;$modulename$&quot; /&gt;&#10; &lt;/route&gt;&#10; &lt;/router&gt;&#10;&lt;/config&gt;&#10;" toReformat="true" toShortenFQNames="true">
<variable name="id" expression="decapitalize(String)" defaultValue="" alwaysStopAt="true" />
<variable name="frontname" expression="decapitalize(String)" defaultValue="" alwaysStopAt="true" />
<variable name="modulename" expression="capitalizeAndUnderscore(String)" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:system" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Config:etc/system_file.xsd&quot;&gt;&#10;&lt;/config&gt;" toReformat="false" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:ui:listing" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;listing xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Ui:etc/ui_configuration.xsd&quot;&gt;&#10;&lt;/listing&gt;" toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:view" value="&lt;?xml version=&quot;1.0&quot; ?&gt;&#10;&lt;view xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Config/etc/view.xsd&quot;&gt;&#10; &lt;vars module=&quot;$module$&quot;&gt;&#10; &lt;/vars&gt;&#10;&lt;/view&gt;&#10;" toReformat="true" toShortenFQNames="true">
<variable name="module" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:webapi" value="&lt;?xml version=&quot;1.0&quot;?&gt;&#10;&lt;routes xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&#10; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Webapi:etc/webapi.xsd&quot;&gt;&#10; &#10;&lt;/routes&gt; " toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
<template name="magento2:xml:widget" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;widgets xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&#10; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Widget:etc/widget.xsd&quot;&gt;&#10;&lt;/widgets&gt;&#10; " toReformat="true" toShortenFQNames="true">
<context>
<option name="XML_TEXT" value="true" />
</context>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment