PHPStorm: Tips, Hacks and Shortcuts That Will Make Your Life Easier

Imagine a life without refactoring, CSS auto-complete, step-debugging or code completion! Don't you instantly visualize yourself as a... "web mine digger", sweating your way to completing even the most common tasks? Buried under a heavy load of drop-down menus to go through, repetitive tasks to keep carrying out, a maze-like infrastructure of code to navigate through with no hints on which shortcuts to take. You simply can't imagine your workflow, as a Drupal developer without an IDE anymore, right?

And PHPStorm sure makes the most “seductive” one thanks to its huge set of features and keyboard shortcuts that it comes to streamline your workflow with.

Speaking of which, I've striven (for it sure was a challenge, considering the tones of features, settings and less known “hacks” that PHPStorm “spoils” us with) to select “la crème de la creme” in terms of PHPStorm features aimed to optimize your personal workflow. Here they are:

 

Preferences: You're Given Unlimited Power of Customization

Use it to the fullest! Or, even better: adapt this power to your given project's needs/workflow's particularities:

Preferences -> IDE -> Editor -> Appearance -> Show method separators: it uses lines to separate your methods, adding a more blocky look and feel to their overall appearance

Preferences -> IDE -> Editor -> Smart Keys -> Surround Selection: it enables you to surround a marked text by just typing a quote (or a brace)

Preferences -> IDE -> Editor -> Auto Import: the custom change in PHPStorm which turns full namespaces into use statements

 

Keymap: You Can Make It Fit Your Workflow in a Bit!

Adaptability at its best! PHPStorm enables you to rebind each existing keybiding and, moreover, to add new bindings to unmapped features, as well. 

And all this for turning the whole process of adapting the keymap to your personal workflow into a matter of a few simple set ups!

 

In short: even if you've got yourself familiarized with another text editor, you'll get a “deja vu” feeling once you switch to PHPStorm!

 

19 PHPStorm Shortcuts That Will Make Your Dev Life So Much Easier

When it comes to improving your workflow, as a Drupal developer in Canada, keyboard shortcuts are some priceless time-saving hacks. The more of them your IDE “spoils” you with, the more productive you get.

Luckily PHPStorm has an almost “bottomless sack” of efficiency-boosting shortcuts. Here are my “can't work without” ones:

  1. CMD+SHIFT+A: allows you to track down a particular functionality, to trigger the Actions pop up (just use the action's name as your search word) and to navigate to the settings within the editor; it also unfolds the installed plugin's feature set for your to... dig through. 

     
  2. CTRL+Enter: triggers the code generator drop down (this way you're enabled to quickly overwrite the current methods, for instance)

     
  3. Refactor -> Extract -> Interface:  allows you to set up a new interface from any of the available classes

     
  4. ALT+CMD+M: hit this key “combo” only after you've selected code in a method and create a brand new method from the given selection

     
  5. Double hit SHIFT: to open up a global search

     
  6. SHIFT+ENTER: add a new line of code right after the current one

     
  7. CTRL+ALT+ENTER: add a line before the current line of code 

     
  8. CTRL+D: make a duplicate of the current line 

     
  9. CTRL+Y: remove the current line

     
  10. CMD/CONTROL+SHIFT+Backspace: allows you to quickly navigate to the latest edit point

     
  11. CMD+OPT+L: use this shortcut when you're in a file (and after you've predefined your coding standards in Preferences> Code Style) to format the whole file (or “chunk” of code) to your pre-defined coding standards

     
  12. CTRL+OPT+/- Auto-indent Lines: indents your code 

     
  13. ALT+J: adds multiple cursors, one for each occurrence of the word that you're cursor's currently selecting

     
  14. Hit F2: your cursor will jump right to the next error in your file

     
  15. SHIFT+F2: jump to the previous error in your file

     
  16. Hit the “Scroll from Source” button: track down your current file in your project panel and scroll it into view

     
  17. CTRL+P: use this shortcut, as you place your cursor within the parenthesis of a function call, to make it reveal its parameter info to you

     
  18. CMD+O: trigger an “Open Class” dialogue and enter the right search words to navigate right to your target class within your file

     
  19. ALT+UP/ALT+Down: navigate to the next/previous method within the current class

     

More PHPStorm Features to Optimize Your Personal Workflow With

… and (therefore) to streamline any web development process that you'll take up!

For there sure is more! More PHPStorm tips and tricks aimed to simplify your entire workflow:

  • code completion and code analysis: you get to easily access any method or class in your web project

     
  • automated addition of use statement/instant alert whenever you try to access a method that don't apply in the current scope (it “warns” you that you won't be able to access that particular method)

     
  • reformatting of the code (CTRL+ALT+L) according to a set of pre-defined (project-specific) rules

     
  • built-in Version Control: allows you to test and gauge the potential impact that your current edits might have on your project 

     
  • multiple databases (remote and local) full support: you won't need to separate applications for the same web project 

     

A Few Annoyances to Expect

For I did experience some of those, too! It's not all “rainbows and butterflies”, no IDE can guarantee you that:

  1. it does get bogged down if you're “joggling” with multiple projects simultaneously; it will consume too much of your ram and... well... become slightly sluggish

     
  2. don't expect the conventional CMD+UP/CMD+Down to actually get you to the top/bottom of your file when using PHPStorm. It's a tricky little drawback that can easily turn into an annoyance after a while.

And yet, these 2 little annoyances (compared to the “tones” of cool features), still can't overthrow PHPStorm from the top of my favorite IDEs list. It's my reliable “ally” whenever, as an always too busy Drupal developer, I want to get things done time-effectively and correctly! Which is yours?