When switching from dark to light, or the other way around, it takes some getting used to, however, always consider it as a fresh start which might even motivate you to write more code! If you are working late and it’s dark, you might prefer a dark theme.
For example, if you are in a bright environment, you need a light theme that will help you relax your eyes. However, it’s not only for you to look fancy in front of colleagues, but you also need a theme that will suit your environment and a font that is easy to read. You’ll be staring many hours at that exact screen, so you need to take your time and make it look appealing. As I mentioned in the last email, having a good theme and font is essential. Today, we’ll explore one of the most interesting topics for me - making the IDE look good. In the emails, I’m sharing thoughts, news and more about PhpStorm, so make sure you’re not missing anything by signing up for the newsletter!
Making time for regular research to find possible improvements always pays back.This is an archive of the second email from the series - “PhpStorm, But Better!”. It’s always great to discover new features for tools that you already like and use. Live Templates are convenient and really save your time. Those were just some examples that can be useful and I’m pretty sure you will add plenty other as you use this feature more.
So just type the abbreviation of the live template: custom_drupal_form, then press Tab (by default) and receive basic functions for the custom form. Here you can see a variable $FORM_ID$ which you will be able to insert while applying a live template, and that makes it flexible for different modules. Or just start typing emd and choose it from the tooltip.
Now you can just select any node nid (like predefined constant in your code or argument from the url, or nid of related node) and wrap it with emd function. This way it will be easy to search in watchdog for errors debugging. Therefore, by default there will be the first word of a filename, without an extension. In this case – as you can see in the screenshot – I used two of them. Live templates are quite flexible with variables, there are some predefined expressions for most purposes (to manage them, just click *Edit variables *above options). Here I’ve used the variable ‘module’ and created a template for it.
(Shortcut: Alt + ⌘ + J in Mac or Alt + Ctrl + J in Windows):įor easy access and manipulation of field data we usually use entity metadata wrapper, which is provided by Entity API, so it might be a good idea to have a template for it: Now when you select text in your template, you will be able to wrap it with the t function. Make it applicable in necessary file types.
$SELECTION$ – predefined variable, used for surround templates, will be replaced by your selection in code after applying live template. *Template * text – basic logic of the template. 1) t functionįill *Abbreviation *field with the command you want to call the live template with.
The day after installing Live Templates, I have extended the base with 3 new templates useful for me – t function, get entity metadata wrapper and constructor for custom Drupal forms.īelow I would like to show you how to do this. For some of them you can find a predefined template, and if not, you can create one yourself. There are a lot of standard subtasks that developers usually perform when working on projects. There is also an option to add new live templates, and it brings even more benefits. (Tip: if you use OSX & PHPStorm 7+, then you’ll probably need to take one more step before the 7th: ln -s ~/Library/Preferences/WebIde70 ~/.WebIde70 (until bug “.WebIde# not found” is fixed in the main branch)).Īfter installing Live Templates feature, you can check for available templates by opening Preferences and choosing Live Templates in IDE settings.There are many code templates for basic Drupal hooks, render arrays, theme functions (like theme_image, theme_item_list…) and others in the repo that just can speed up your workflow.
The best part about it – if you’re a Drupal dev – is that there is already a repo of live templates for Drupal. One great advantage is Live Templates, which are predefined code fragments that you can insert into your source code. It has a lot of advantages (performance being the main one for me). I’m a Drupal developer and like most of my colleagues, I’m excited over PHPStorm.