SilverStripe live templates - Speed up development with SilverStripe live templates for PhpStorm and WebStorm

Overview

SilverStripe live templates

My collection of live templates for WebStorm and PhpStorm, following PSR-2, using PHPDoc, and utilizing PHP 5.4 array shorthand syntax. These templates do not attempt cover every field, variable, nor function, but are a collection of snippets that I frequently use in my daily work. Feel free to open issues to suggest additional templates.

Installation

Download and place the template files inside your IDE's templates/ folder. Where the folder is located depends on the version and type of IDE you are using. Consult this IntelliJ article on where you'll find yours if below table does not work. Restart your IDE after placing the files in the templates folder.

OS Path
Windows \. \config\templates
Linux ~\. \config\templates
OS X ~/Library/Preferences/ /templates

Direct links to specific template files:

Or you can cd to templates/ directory and run:

git clone https://github.com/jjjjjjjjjjjjjjjjjjjj/silverstripe-php-web-storm-live-templates.git .

Then optionally remove the unused files by doing something like rm -rf .git and rm README.md if you don't want them in there.

Usage

When editing a PHP file you can simply type in the short code for the live template and then hit the "Choose lookup Item Replace" keymap binding (tab by default). For example, typing in aa then hitting tab, would expand aa into the following and leaving your cursor in between the single quotes:

/**
 * @var array
 */
private static $allowed_actions = [
    ''
];

List of available templates and their contents

Fields

Direct link to the live template file: https://raw.githubusercontent.com/janneklouman/silverstripe-phpstorm-live-templates/master/SilverStripe%20PHP%20Fields.xml

cbf (check box field)

CheckboxField::create('$NAME$', $LABEL$)$END$

ddf (drop down field)

DropdownField::create(
    '$NAME$',
    $LABEL$,
    $DATALIST$
)$END$

df (date field)

DateField::create('$NAME$', $LABEL$)$END$

fg (field group)

FieldGroup::create(
    $LABEL$,
    [
        $FIELDS$
    ]
)$END$

gf (grid field)

GridField::create(
    '$NAME$',
    $LABEL$,
    $this->$DATALIST$(),
    GridFieldConfig_$TYPE$::create()
)$END$

lf (literal field)

LiteralField::create('$NAME$', $LABEL$)$END$

nf (numeric field)

NumericField::create('$NAME$', $LABEL$)$END$

tf (text field)

TextField::create('$NAME$', $LABEL$)$END$

Functions

Direct link to the live template file: https://raw.githubusercontent.com/janneklouman/silverstripe-phpstorm-live-templates/master/SilverStripe%20PHP%20Functions.xml

gcms (get cms fields)

/**
 * @return FieldList
 */
public function getCMSFields() {

    $fields = parent::getCMSFields();
    
    $END$

    return $fields;

}

log

SS_Log::log( print_r ( $END$, true ), SS_Log::WARN );

t (translate)

_t('$STRING$', '$DEFAULT$')$END$

ucms (update cms fields)

/**
 * @param FieldList $fields
 */
public function updateCMSFields(FieldList $fields) 
{
    $END$
}

"Skeletons"

Direct link to the live template file: https://raw.githubusercontent.com/janneklouman/silverstripe-phpstorm-live-templates/master/SilverStripe%20PHP%20Skeletons.xml

dofs (data object file start)

/**
 * $DESCRIPTION$
 *
 * @author $AUTHOR$
 * @package $PACKAGE$
 * @subpackage $SUBPACKAGE$
 */
class $CLASS$ extends DataObject
{
    $END$
}

defs (data extension file start)

/**
 * $DESCRIPTION$
 *
 * @author $AUTHOR$
 * @package $PACKAGE$
 * @subpackage $SUBPACKAGE$
 */
class $CLASS$Extension extends DataExtension
{
    $END$
}

efs (extension file start)

/**
 * $DESCRIPTION$
 *
 * @author $AUTHOR$
 * @package $PACKAGE$
 * @subpackage $SUBPACKAGE$
 */
class $CLASS$ extends Extension
{
    $END$
}

pfs (page file start)

/**
 * $DESCRIPTION$
 *
 * @author $AUTHOR$
 * @package $PACKAGE$
 * @subpackage $SUBPACKAGE$
 */
class $CLASS$ extends Page
{
    $END$
}

class $CLASS$_Controller extends Page_Controller 
{
}

Static variables

Direct link to the live template file: https://raw.githubusercontent.com/janneklouman/silverstripe-phpstorm-live-templates/master/SilverStripe%20PHP%20Static%20Variables.xml

aa (allowed actions)

/**
 * @var array
 */
private static $allowed_actions = [
    '$END$'
];

bmm (belongs many-many)

/**
 * @var array
 */
private static $belongs_many_many = [
    '$VAR$'  => '$END$'
];

d (defaults)

/**
 * @var array
 */
private static $defaults = [
    $END$
];

db (database)

/**
 * @var array
 */
private static $db = [
    '$VAR$' => '$END$'
];

df (default sort)

/**
 * @var string
 */
private static $default_sort '$END$';

hm (has many)

/**
 * @var array
 */
private static $has_many = [
    '$VAR$'  => '$END$'
];

ho (has one)

/**
 * @var array
 */
private static $has_one = [
    '$VAR$'  => '$END$'
];

mm (many many)

/**
 * @var array
 */
private static $many_many = [
    '$VAR$'  => '$END$'
];

mmef (many many extra fields)

/**
 * @var array
 */
private static $many_many_extraFields = [
    '$RELATION$' => [
        '$NAME$' => '$TYPE$'
    ]
];

sef (searchable fields)

/**
 * @var array
 */
private static $searchable_fields = [
    $END$
];

suf (summary fields)

/**
 * @var array
 */
private static $summary_fields = [
    $END$
];
You might also like...
Twig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHP

Twig, the flexible, fast, and secure template language for PHP Twig is a template language for PHP, released under the new BSD license (code and docum

☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites.

Latte: amazing template engine for PHP Introduction Latte is a template engine for PHP which eases your work and ensures the output is protected again

PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages

PHPTAL - Template Attribute Language for PHP Requirements If you want to use the builtin internationalisation system (I18N), the php-gettext extension

A complete and fully-functional implementation of the Jade template language for PHP

Tale Jade for PHP Finally a fully-functional, complete and clean port of the Jade language to PHP — Abraham Lincoln The Tale Jade Template Engine brin

The free-to-use template for your Imagehost-website made with PHP, HTML and CSS!
The free-to-use template for your Imagehost-website made with PHP, HTML and CSS!

The free-to-use template for your Imagehost-website made with PHP, HTML and CSS! Some information before we start This repo is only code related, to a

The free-to-use template for your Imagehost-website made with PHP, HTML and CSS!
The free-to-use template for your Imagehost-website made with PHP, HTML and CSS!

The free-to-use template for your Imagehost-website made with PHP, HTML and CSS! Some information before we start This repo is only code related, to a

⚡️ Simple and fastly template engine for PHP

EasyTpl ⚡️ Simple and fastly template engine for PHP Features It's simple, lightweight and fastly. No learning costs, syntax like PHP template It is s

A PHP project template with PHP 8.1, Laminas Framework and Doctrine

A PHP project template with PHP 8.1, Laminas Framework and Doctrine

Laravel Live Templates for PhpStorm
Laravel Live Templates for PhpStorm

Laravel Live Templates for PhpStorm How to: Go to Preferences | Tools | Settings Repository Add Read-only Source https://github.com/koomai/phpstorm-la

PHPStorm Live template preferences for Magento 2 Projects
PHPStorm Live template preferences for Magento 2 Projects

Magento 2 PHPStorm Preferences This project is intended to setup useful PHPStorm Templates for Magento 2 Projects. Disclaimer This project overrides t

PHPStorm Magento 2 File Templates

phpstorm-m2-filetemplates PHPStorm Magento 2 File Templates Useful file templates for working with Magento 2. To install, place the files directly in

Laracademy Generators - is a tool set that helps speed up the development process of a Laravel application.

Laracademy Generators Laracademy Generators - is a tool set that helps speed up the development process of a Laravel application. Author(s): Laracadem

Silverstripe-searchable - Adds to the default Silverstripe search by adding a custom results controller and allowing properly adding custom data objects and custom fields for searching

SilverStripe Searchable Module UPDATE - Full Text Search This module now uses Full Text Support for MySQL/MariaDB databases in version 3.* Adds more c

Silverstripe-solr-search - Advanced searching with SilverStripe, Solarium and Solr

Master is no longer the main branch. If you are using dev-master, switch to dev-primary Modern SilverStripe Solr Search Full documentation or see the

Silverstripe-masquerade - SilverStripe module to allow users to "masquerade" as other users

SilverStripe Masquerade Module About This module is designed to allow an Administrator to "login" as another "Member" without changing their password

Silverstripe-debugbar/ - SilverStripe DebugBar module
Silverstripe-debugbar/ - SilverStripe DebugBar module

SilverStripe DebugBar module Requirements SilverStripe ^4.0 maximebf/php-debugbar jdorn/sql-formatter Installation You can install the debug bar with

Silverstripe-fulltextsearch - Adds external full text search engine support to SilverStripe

FullTextSearch module Adds support for fulltext search engines like Sphinx and Solr to SilverStripe CMS. Compatible with PHP 7.2 Important notes when

A SilverStripe module for conveniently injecting JSON-LD metadata into the header of each rendered page in SilverStripe

A SilverStripe module for conveniently injecting JSON-LD metadata into the header of each rendered page in Silver

Live Helper Chat - live support for your website. Featuring web and mobile apps, Voice & Video & ScreenShare. Supports Telegram, Twilio (whatsapp), Facebook messenger including building a bot.

Live helper chat It's an open-source powered application, which brings simplicity and usability in one place. With live helper chat you can bring live

Owner
North Creation Agency
North Creation Agency
A SilverStripe Module with template methods to quickly make use of FocusPoint, LazySizes, and Object-fit

LazyFocusFit A SilverStripe module with template methods to quickly make use of FocusPoint, LazySizes and object-fit. Requirements PHP FocusPoint JS/C

Evans Hunt 9 Nov 4, 2022
Foil brings all the flexibility and power of modern template engines to native PHP templates

Foil brings all the flexibility and power of modern template engines to native PHP templates. Write simple, clean and concise templates with nothing more than PHP.

Foil PHP 167 Dec 3, 2022
Yii2 Gii Extended templates and generators

model template with TimestampBehavior and BlameableBehavior according to columns

潘文斌 1 Feb 12, 2020
PHP template engine for native PHP templates

FOIL PHP template engine, for PHP templates. Foil brings all the flexibility and power of modern template engines to native PHP templates. Write simpl

Foil PHP 167 Dec 3, 2022
Contao extension to provide content templates for pages.

Contao Content Templates In Contao, the regular content of a page can be made up of different articles, each assigned to different sections of a page

inspiredminds 7 Oct 11, 2022
Renders Mithril components to HTML for use in blade templates

Flarum Mithril2Html Uses Chrome Puppeteer via Spatie Browsershot to render Mithril components as static HTML. Follow Browsershot instructions to setup

Clark Winkelmann 3 Nov 13, 2022
Document templates Laravel package is intended for creating/managing user editable document template

Document Templates Introduction Document templates Laravel package is intended for creating/managing user editable document templates, with ability to

42coders 139 Dec 15, 2022
Qiq templates for PHP 8.

Qiq Templates for PHP 8 This package provides a PHP 8.0 implementation of the TemplateView and TwoStepView patterns using PHP itself as the templating

null 18 Nov 24, 2022
Simple PHP templating system for user editable templates.

Simple template Simple PHP templating system for user editable templates. Idea Most applications need to render templates that insert safely treated v

Baraja packages 1 Jan 23, 2022
Provides TemplateView and TwoStepView using PHP as the templating language, with support for partials, sections, and helpers.

Aura View This package provides an implementation of the TemplateView and TwoStepView patterns using PHP itself as the templating language. It support

Aura for PHP 83 Jan 3, 2023