My favorite PhpStorm features and keyboard shortcuts
Tags: articles, phpstorm, tutorial, ide
Published: 2019-06-24 09:46:07

---
title: My favorite PhpStorm features and keyboard shortcuts
published: true
tags: Articles,PHPStorm,Tutorial,IDE
canonical_url: https://42coders.com/my-favorite-phpstorm-features-and-keyboard-shortcuts/
---

Working as a software developer in the past 10+ years, I’ve used couple of IDEs and text editors (e.g 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 a 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 definition, can be used on functions, methods, classnames, 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 afterwards  
**⌘** **+ ]** – 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 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.

![](https://42coders.com/wp-content/uploads/2019/06/phpstorm_skip_copy_empty-1024x452.png)

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](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 comments below.

The post [My favorite PhpStorm features and keyboard shortcuts](https://42coders.com/my-favorite-phpstorm-features-and-keyboard-shortcuts/) appeared first on [42 Coders](https://42coders.com).