58 PhpStorm Tips & Tricks

Powered by Mastering PhpStorm video course

#58
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #58 - Move cursor to matching brace

Have you ever tried to find a matching brace? I have many times!

Did you know that PhpStorm has a shortcut to do that? It's called "Move Caret To Matching Brace ", and it also works for HTML tags ๐Ÿ”ฅ

Thanks for the tip @SeeBigg ๐Ÿ™๐Ÿป


#57
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #57 - Remove unused imports

It's very easy to end up with unused imports in your classes. Glad there is a nice shortcut to remove them.

It's called optimize imports and also sorts your imports alphabetically. ๐Ÿ‘


Ready for more?

Mastering PhpStorm Logo text

Tips & Tricks was just the beginning. In my new video course, I cover all the essential features of PhpStorm like Refactoring, Testing, Debugging and Git in detail.

Show Me
#55
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #55 - Check RegExp Inline

We all know how hard it can be to debug regular expressions. It's not always fun. ๐Ÿ™ˆ

But it just became a lot easier. PhpStorm has an inline action where you can test your expressions. โค๏ธ

In this example, I have different "YouTube" URLs and I need the video id.

Tip by @wiifm ๐Ÿ™๐Ÿป


#54
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #54 - Modified Line Colors

Whenever you modify your code, you can see a little color indicator on the side. When you click it, you even see the what has changed. (change list)

The used colors are defined by your theme. But like everything in PhpStorm, you can change those colors too. Check the preferences for "Color Scheme -> VCS" and "Color Scheme -> Diff & Merge".


#53
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #53 - Lorem ipsum

We all sometimes need a placeholder text. In PhpStorm, you can type "lorem" and expand it with the tab key.

But you can also specify the amount of words by adding a number "lorem5" or even combine it with an emmet shortcut like "p>lorem5"

Thanks for the tip @freekmurze ๐Ÿ™๐Ÿป


#52
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #52 - Override Methods

When you want to override a method, PhpStorm helps you already out while typing it.

But there is also a shortcut to open the "Override Methods" popup. It lets you select a method, and also specify if you like to copy the parent's DocBlock.

Thanks for the tip @simioluwatomi ๐Ÿ™๐Ÿป


#51
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #51 - Search By Capital Characters

I just learned something new! (from jphooiveld) While looking for specific files, you can just type the capital characters of the word.

Like "UCCT" for my "UpdateChannelsCommandTest" class.

This is super useful when you have similar file names and you struggle finding the correct one. It will save you a lot of time.


#50
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #50 - Close All Active Tool Windows

While using PhpStorm, you often need to work with some windows like the terminal, project tree, or VCS. To close them, you can use the same shortcut you use for opening them. This takes a few seconds when you have multiple windows open.

Much better is the shortcut "Hide All Windows", which closes all active tool windows. ๐ŸŽ‰

This is the only shortcut I use these days for closing windows.


#49
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #49 - Navigate Back & Forward

While scanning through files, you often need to go "back" to your last cursor position.

The shortcuts "navigate back" and "navigate forward" are your friends in this regard. This is especially useful when scanning from a code-base or just a long file. I use them every day!
Here are the used shortcuts. Screenshot of keymap showing the used shortcuts of the above video. In video example below, I follow Laravel's kernel and route flow while using those shortcuts.


#48
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #48 - Store Window Layout

Do you hate to adapt your tool windows position with every project again? (like file tree from left to right)

Not anymore! You can store them.


#47
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #47 - Open Multiple Files

When working with tabs, you can select multiple files from pop-ups by holding "shift" and open them together. ๐Ÿ‘€


#46
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #46 - No need for $this

In a class, you don't have to write "$this->" every time to get auto-completion for properties or methods. It just works. This saves a lot of time. ๐Ÿค—


#45
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #45 - Run Tests Before A Commit

With the release of @phpstorm 2021.2 today, you have more pre-commit options available. I'm excited that I can finally run a specific test configuration before a commit. ๐Ÿค—


#44
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #44 - Speed Search ๐Ÿ”Ž

In EVERY dialog, prompt, tree, or folder you can start typing to search for something specific.

It's a simple feature but a life changer when you use it all the time and avoid the Mouse face.


#43
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #43 - Learn About Commit Options

Commit options let you define actions to run before a commit like:

* Reformat Code
* Check TODO
* Analyze code
* etc.


Forget a todo? PhpStorm tells you before doing the commit.๐Ÿ‘


#42
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #42 - The Project View

Next to the search features, I like to work with the project view too. 3 important shortcuts can help:

1๏ธโƒฃ Open File in Project View (Fire my favorite one)
2๏ธโƒฃ Expand Tree
3๏ธโƒฃ Collapse Tree


#41
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #41 - Inline Refactoring

Just a tiny refactoring feature but so useful. Great that you can trigger it from both sides. (where the variable is defined and used)


#40
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #40 - Git Annotations

Need to check who changed a specific line of code? Or who else was working on this current file?

Git annotations are your friend. Handshake


#39
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #39 - Find In Files

If you need to look for strings in your app you can select or copy the string and open "Find in Files". This way it will automatically paste this string and look for it. โœŒ


#37
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #37 - Easily Replace Quotes

How many times do you replace quotes? For me, definitely more than I want to :-)

I'm glad you can do that easily with a context action.


#36
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #36 - CLI Features

Did you know that you can use some features right from the command line? (thx @nuernberger_me)

- Create a launch script
- Open up file/project
- Open diff dialog
- Or merge dialog


#35
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #35 - Set Conditional Breakpoints

While debugging you are often only interested in one specific case that you want to take a closer look at.

That's when you should use conditions for your breakpoints.


#34
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #34 - Learn About Inline Watches

While debugging you often need to have quick look at specific values: Welcome inline watches

- Define what you need to see (with auto-completion of course)
- See it directly in the editor๐Ÿ˜ฎ


#33
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #33 - Debug Collections In Your App

To debug collections or chained method calls with Xdebug you can evaluate every call separately at a breakpoint without changing the code itself. ๐Ÿ˜ฎ


#32
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #32 - Toggle Class Type When Creating A New One

Today's tip was brought to me by @freekmurze.

When creating a new class, you can toggle the templates "class", "interface", and "trait" by using your up and down keys. Pretty neat and fast! ๐Ÿ’จ


#31
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #31 - The No Mouse Commit

When you commit/push with PhpStorm tools, you can press the "Alt" key to show letters to trigger the "commit" or "push" button.

This means no mouse is needed for the whole process. ๐Ÿ˜


#30
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #30 - The Key Promoter X Plugin

Sometimes we fall into a habit of using the mouse for something, where we could have used a shortcut.

Key Promoter X is a plugin that tells of such situations. It reminds you by showing the shortcut you should use instead.


#29
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #29 - Run Tests

Another cool feature using the "Run Anything" prompt and custom "Run configurations" to run specific tests like unit, feature, or all.

Especially being able to run "all test" is something I missed an easy solution for a long time. ๐Ÿ˜


#28
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #28 - Run Terminal Tasks

We often tend to run tasks from within the Terminal. That's fine, but what I prefer is to run them through "Run Anything".

This way I don't have to open up the Terminal and I have one place to check my running tasks.


#27
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #27 - Toggle Scope For Searches

I hope you already know your shortcuts for specific searches. ( files, classes, etc.)

One little trick here is if you press the shortcut again it toggles the scope of the search between "Project Files" and "All Files" Left-pointing magnifying glass


#26
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #26 - Hello Changelist

In a repository, all changes will the stored to the "Default Changelist" in PhpStorm.

When you edit more files than needed for the next commit, it makes sense to order them in custom changelist.


#25
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #25 - The Run Anything Dialog

The "Run Anything" prompt can be used to quickly run tasks like from npm/Yarn, but did you know that you can run Artisan calls too? ๐Ÿคฉ

Pretty handy for triggering a command without opening the terminal.


#24
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #24 - Toggle Plugins On And Off

I need to activate/deactivate some PhpStorm plugins more often. Gladly I can do that also through the global search.

Be aware, some plugins require a restart.


#23
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #23 - The Presentation Assistant

The Presentation Assistant is great to show the shortcuts you are using while talks or presentations.

By default it includes the default keys. But you can change that to show the ones you have actually set ๐Ÿ‘


#22
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #22 - Tailwind CSS Support

If you work with #TailwindCSS, make sure to use the latest 2020.3 version of PhpStorm to support auto-completion and preview of the rules on mouse-over.


#21
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #21 - Open A New File In Split Mode

With PhpStorm 2020.3 you are able to open files directly in split mode. The shortcut works from within the sidebar, but also from the other windows like "recent files" which I really love.

PS: default shortcut is "shift+enter"


#20
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #20 - Search PhpStorm Features Through Actions

Actions are commands + shortcuts in PhpStorm. With the action search, you can easily trigger features without knowing shortcuts.

๐Ÿ’กEven better: If you use an action a lot, just assign a shortcut right from the search with alt+enter.


#18
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #18 - Initialize Properties Automatically

Constructor arguments can be initialized by PhpStorm. Here are some interesting facts:

1. You can initialize multiple fields
2. PHP < 7.4 it uses PHP DocBlocks
3. You can edit the template
4. >= 7.4 it skips the DocBlock โค๏ธ


#16
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #16 - File Colors

This one is actually a tip by @brendt_gd . You can use scopes in combination with file colors to create highlighted sections in your project's tree view.

It improves file recognition and also works with tabs ๐Ÿณ๏ธโ€๐ŸŒˆ


#15
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #15 - Multi Cursors Part 2

I got some feedback about more ways to use multiple cursors in PhpStorm, so here are two more:

- add carets to the end of selected lines
- clone caret alt+alt ๐Ÿ”ผ/๐Ÿ”ฝ


#14
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #14 - The Productivity Guide

The Productivity Guide shows you an overview of your PhpStorm features usage. It tells you about what you use regularly and what you never used before.

It's also great to learn about new features.


#13
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #13 - I Can't Live Without The File Structure Tool

When you're checking a longer class, the "File Structure" tool window becomes super handy. It...

๐Ÿ‘€ gives an overview of given properties/methods
๐Ÿ”Ž lets you search for sthg specific
๐Ÿ”Ž even lets you search params names


#12
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #12 - If / Else Transformations

There are numerous things you can do with if/else statements in PhpStorm like:

- flip condition
- simplify them
- get rid of "else" (EA Inspections plugin)


#11
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #11 - Multi Cursor Usage Is a Must

Multi-cursors are so powerful and a must-have in every code editor.

Here are three ways of using them in PhpStorm:

1โƒฃ Atl + click
2โƒฃ Alt + shift + hold click + move up/down
3โƒฃ Multiple select


#10
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #10 - Postfix Templates

Next to "Live Templates" there are also "Postfix Templates" which you can trigger by putting a "." after an expression and then add a key.

This way you don't have to replace the cursor if you wrote the expression first.

".dd" is a custom one ๐Ÿ˜ˆ


#9
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #9 - The Best Way To Explore Code

I use the "Go to declaration" shortcut all the time to check a class/method that was used. This was essential for learning how Laravel works under the hood.

But the same shortcut can also be used on the declaration to see where else it is used. ๐Ÿ”Ž


#8
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #8 - Hide The Current Active Tool Window

There are shortcuts for all tool windows like the sidebar, console, etc. The same close it again.

What I find more useful though is to use the "hide active tool window" shortcut. This way you don't have to think about which toolbar it is anymore.


#7
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #7 - The Best Way To Run Tests

To run a specific test depending on your cursor position, use the "Run context configuration" shortcut.

- Inside a method โžก๏ธ run this test method
- Between methods โžก๏ธ run whole file

The same shortcut used in all three examples in the video.


#6
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #6 - Surround With Using Emmet

Last time I showed you the "Surround With" feature, but there is more to it. @pronskiy gave me a hint that we can use it together with Emmet. ๐Ÿ˜

Now, this gets even more powerful.


#5
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #5 - Surround Selection With

When I needed a tag around some given text, I always created the tag first, then put the text in. I got used to this tedious behavior ๐Ÿ™ˆ

Recently I discovered the "Surround With" feature. ๐Ÿ˜ฎ

Such details make so much difference in your workflow!


#4
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #4 - Convert To Arrow Functions

You can easily convert functions to arrow functions by using the "show context action" (โŒฅ + enter) shortcut.

My favorite aspect is that you do not need "use" anymore to pass variables to the function. Less code is good code ๐Ÿ‘Œ


#3
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #3 - Style Your IDE Through The Global Search

You can style many parts of your IDE within the global search without visiting the settings page like the:

- ๐Ÿ’กstatus bar
- ๐Ÿž breadcrumbs
- ๐Ÿ—‚tabs placement
- ๐Ÿงญ navigation bar
- etc.


#2
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #2 - Auto-complete For Composer Packages

Version 2020.1 brought some cool new Composer features like showing the exact used version of a package in the composer.json file.

But did you also know that it autocompletes new requirements now? ๐Ÿ˜


#1
photo of Christoph Rumpel

Christoph Rumpel ๐Ÿค 

@christophrumpel

๐Ÿงช PhpStorm Tips & Tricks #1 - Use Live Templates

Here is one of my favorite live templates to create a simple new test exactly how I like them. Customizing everything to your needs is a key to workflow that you can benefit the most from. ๐Ÿ•บ

What templates did you create?


You made it till the end ๐Ÿ‘
I'm sure you're ready for more!

Mastering PhpStorm Logo text

Tips & Tricks was just the beginning. In my new video course, I cover all the essential features of PhpStorm like Refactoring, Testing, Debugging and Git in detail.

Show Me