PHPStorm

My favorite PhpStorm features and keyboard shortcuts

Daniel Verner -

Eclipse, Netbeans, Sublime Text, Notepad++, etc), but in my opinion, the best one is PhpStorm. It has similar features as the other IDEs, but as opposed to the others, it just works. You don’t need to install fancy plugins, and it comes with reasonable default settings so no need to do a lot of configuration in the beginning (of course it has plenty of configuration and customization options). Let’s see what are the features I like and use in my day to day work. The features described below should work on any operating system, but the keyboard shortcuts are for macOS.

Navigation

⌘ + click – Jump to the definition, can be used on functions, methods, class names, variables, and constants. Very useful tool to navigate through the source code, it also works on vendor directory
⌘ + [ – Navigate back to the previous position, can be used in combination with the previous feature: check a function by jumping to its definition and navigate back to the previous position afterward
⌘ + ] – Navigate forward: the opposite action to the previous
⌘ + O – Search for classes, a handy feature to quickly open a desired class
⌘ + ⇧ + O – Search for files, similar to the previous one but it searches for the file name instead of class
⌘ + L – Jump to the given line in the current file

Code

⌘ + / – Comment/uncomment the selected line(s)
⌘ + Backspace – Delete the current line
⌘ + ⌥ + L – Reformat code, apply the rules of the configured coding standard for the currently open file
⌘ + N – Generate: can be used to generate class constructor, getters and setters. Simply add the necessary properties to the class, press the key combination choose the properties to initialize in the constructor, and PhpStorm will generate the constructor with all the necessary arguments, and set the properties accordingly.

File creation

From the New… context menu you can create Classes, Interfaces, and Traits, and it will create the boilerplate code for you according to the name and configuration you set in the dialog.

Another useful feature is to create a PHPUnit test. In the dialog, you can choose the class and also the methods for testing, and the IDE will generate all the test cases for the selected methods.

Debugging

F8 – Step over the next function/method call
F7 – Step into the function/method call
⌘ + ⇧+ R – Run the debugger after it has stopped at a breakpoint

Refactor

⌘ + ⌥ + M – Extract method, I’ve recently heard of it and it works very well. Just select a part of the code to extract as a method, and it will create the method with all the necessary arguments.

Copy/Paste

Regarding the copy-paste, PhpStorm has a cool and a really annoying feature. The cool feature is the Paste History: ⌘ + ⇧ + V – opens a dialog to choose from the recently copied items.
The most annoying feature in the PhpStorm is that by default it allows you to copy nothing, e.g. if nothing is selected and you press the ⌘ + C, it will simply delete the content of the clipboard. It happened a lot that I’ve copied something and when tried to paste it I’ve pressed the ⌘ + C instead of ⌘ + V and I had to copy it again. It is especially problematic if you’ve cut something, you need to undo the cut to be able to copy it again (or use the paste history).

Fortunately, you can disable this behavior:
Invoke Help | Find Action… (Ctrl (Cmd on Mac)+Shift+A), type Registry and select the Registry… item that appears. Enable the editor.skip.copy.and.cut.for.empty.selection option there.

Credit for this solution goes to the author of the following StackOverflow answer:
https://stackoverflow.com/questions/32895522/disable-copying-entire-line-when-nothing-is-selected-in-intellij

Do you know some other great features of PhpStorm I haven’t mentioned here? Please share it in the comments below.

Tags: PHPStorm · IDE · Shortcuts

Want products news and updates?

Sign up for our newsletter to stay up to date.

We care about the protection of your data. Read our Privacy Policy.

Impressions from our Team

  • Happy birthday 🎁🎈🎂 Filip - #

  • Another day another #mandarinacakeshop 🎂 😀 - #

  • Happy Birthday Ognjen! And marry Christmas to all other 🎄#notacakeshop - #

  • #Office #Garden - #

  • #workhard - #

  • #belgrade #skyline - #

  • #happybirthday Phil :) - #

  • #happybirthday Stefan 🥂 - #

  • #happybirthday Lidija 🍾 - #

  • Say hi 👋 to our newest team member ☕️ - #

  • #bithday #cake 😻 - #

  • #stayathome #homeoffice #42coders - #

  • #stayathome #homeoffice #42coders #starwars :) - #

  • #stayathome #homeoffice #42coders - #

  • We had a really nice time with #laracononline #laravel - #

  • Happy Birthday 🎂 Miloš - #

  • Happy Birthday 🎂Nikola - #

  • #42coders #christmas #dinner what a nice evening :) - #

  • Happy Birthday 🎂 Ognjen - #

  • Wish you all a merry Christmas 🎄🎁 - #

See more!

© 2024 42coders All rights reserved.