Recently I decided to switch my IDE from the amazing Visual Studio code back to PhpStorm which was my preferred IDE of choice for years. Thing is, after an absence of almost two years it’s near impossible to remember keyboard shortcut that one uses in the application.
The purpose of this knowledgebase article is to document some of the common shortcuts, tips, tricks, and customizations I’ve do to get that wonderful developer experience.
Table of Contents
When refactoring, don’t include comments.
Probably the most powerful thing about PhpStorm is it’s Laravel integration. Thing is, it doesn’t just work out of the box. You have to install the Laravel IDE Helper.
composer require --dev barryvdh/laravel-ide-helper
The main reason for doing this is to avoid these Static method warnings such as below:
The Material Light theme is used for now. Darcula is great but the colours a bit dark and it got a bit old
Googled a bit and found a theme that is based on the Visual Studio default theme called Dark – Default. For switching between IDEs this will be useful in the short term. https://plugins.jetbrains.com/plugin/12255-visual-studio-code-dark-plus-theme
File / Settings / Editor / Font
The default font was Jetbrains Mono, changed to DejaVu, and 14 1.1 spacing.
- Return main menu after hiding?
- SHIFT SHIFT Actions / Type ‘main menu’
- Control `
- View Mode
- Enter / Exit Distraction Free Mode / Full Screen Mode / Zen Mode
- View Mode
- Alt ENTER
- Contextual actions can even be used to add to dictionary
- Refactor / Rename
- Shirt F6
- Format Code
- CONTROL ALT L
- Control Shift 10
- Run test under cursor
- Control SHIFT F
- Find anything
- Control ALT-S
- Settings. You’ll be using this a lot in the beginning
- Control ALT-M
- My favourite, Extract Method
- Switch to Terminal
- ALT F12
- Find any file
- Optimize Imports
- Control ALT-O
That’s probably the most important one to remember because it quickly gets on to any file.
Edit .md files
Drag and Drop Actions
I’ve recently discovered that moving the Structure on the left to the top of a the page is really useful for the larger and larger methods I’m building.
What I’m not crazy about it that PhpStorm doesn’t exclude it’s default settings from Git. For now I had to exclude:
/_ide_helper.php .phpstorm.meta.php .idea
Fix warning “Language level was set to 7.0
…but when you’re using PHP 8?
File / Settings / Languages & Frameworks / PHP
Project configuration files can be added to Git
“Don’t Ask Again” and don’t add because it’s just more clutter for other (open source) users.
What we still have to found out 🙂
- Refactor under cursor
- Extract method, Control ALT M insists on creating PHPDocs and this is really annoying
- How to close all windows
Here are some other observations about switching back
- PhpStorm has a very clear highlight of where code has just been changed
- PhpStorm really goes all the way to highlight problems in your code. If you’re using Laravel and you haven’t installed (and correctly set up) the IDE helper it’s completely overwhelming.
- Visual Studio doesn’t copy the $ when copying a word – I actually prefer the way PhpStorm does it
- PhpStorm is way more technical than Visual Studio Code
- You can see PhpStorm was made in Java…it’s a bit sluggish / slow. It’s great though! But it’s possible to witness the slowness.