PhpStorm is my favorite IDE for coding in PHP: pretty stable, you can do a lot with it. A shed load of stuff in fact. Even coding!
The guys from Jetbrains tried to integrate every useful tools for a web developer in one software and, I have to say, it is pretty well done!
You can configure easily a debugger, using a terminal, sending requests to your remote or local databases. It has a very good GUI for Git and everything you expect to find in an IDE (auto completion, indexing…).
Moreover there are search engines for everything: in order to find a particular application setting, some auto completion or a specific class.
Here I share with you some basic tricks I learnt and I use every days.
In this article I use PhpStorm 10 but it is roughly the same things for every version of the IDE, even if jetBrains has the tendancy to change the setting menu pretty often.
You need to know as well that if a particular shortcut is already used by your OS, it won’t work in PhpStorm. In that case you need to change the shortcut in your IDE.
I am using Ubuntu for developing: if you use a mac, simply replace every
cmd in order to use the shortcuts.
Update 2017: PhpStorm was my favorite IDE… before The Change. This article is still valuable for PhpStorm users though…
1. Navigating to a class declaration
You must know this one. You will use it, believe me, a lot.
You can open a class declaration by using
ctrl + click or
ctrl + b when your mouse/carret is on the occurrence.
This will save you a lot of time.
2. Binding shortcuts
I advice you strongly to use as many shortcuts as you can in PhpStorm. It is faster and you will have the feeling you control your IDE. At one point the shortcuts will become natural and you will concentrate on coding instead of losing yourself in the menu.
If you don’t like the shortcuts by default you can change every single one by going to file > Settings > Keymap.
You can even search what you want with the powerful search engine.
Every shortcuts you modify (and only those ones) are saved into a XML file located in ~/.WebIde[your-phpstorm-version]/config/keymaps/
Pretty handy if you don’t remember exactly what shortcuts you modified. You can as well create other shortcuts by adding them directly into the file.
3. Navigating in your open files
You changed something ten minutes ago in a file but you don’t remember exactly where?
You need in that case to use
ctrl + alt + left to go back in your file history quickly.
If you want to go forward again you can use
ctrl + alt + right.
With this useful shortcut you won’t get lost in your file tabs trying to find a file you modified five minutes ago!
4. PhpStorm file internal history
I am totally in love with the file history system in PhpStorm.
Concretely you need to click the right button of your mouse in the editor and go to Local History > Show History.
You will access to a very handy history of the file currently open. You can compare an older version with the current state and reverse the changes.
You can as well use this functionality on folders. If you deleted a file in a precise folder and you want to get it back, just revert his history!
Simple and powerful. A life saviour!
5. Generating getters and setters
Don’t tell me you write your accessors yourself. Yes? Please stop right now and instead go to code > generate or use the shortcut
Then select getters and setters. You can now create getters and setters for every properties you want in one click.
6. Generating control structure
You need to write a useful
while(true == true) around a piece of code in order to blow off your server?
It is very easy in PhpStorm to wrap a block of code with a control structure. Just select some code and go to Code > Surround with or use the shortcut
You can now insert a if, foreach or while quickly around a block of code.
7. Search and replace
Searching is an action I do hundred times a day.
If you want to search in a file you can use the shortcut
crtl + f. If you want to find and replace an occurence you can use
ctrl + r.
You can as well search and/or replace in multiple files or even in the whole project: just select a directory and use the shortcut
ctrl + shift + f and
ctrl + shift + r.
It will search from this directory in every files recursively.
8. Searching a class or a file
You lost the super cool class you created weeks ago to open a ssh connection to the Pentagon?
It happens to all of us.
ctrl + n and type the name of the class you search. PhpStorm will find it for you.
In the same way, if you search a peculiar file you can find it simply typing
ctrl + shift + n.
9. Displaying the tab’s path
You have a file open in your tab but you totally forgot his path? You want to access one of his parent folder?
ctrl + click on the tab and you will see its path. You can as well directly go to one of its parent directory. Pretty handy!
You can as well close a tab buy using
shift + click on it.
If you want to close every tab except one, just use
alt + click on the one you want to keep.
10. Finding every class occurrences
It is possible in PhpStorm to find every occurrences of a class name in a whole project.
For that you have to simply select the name of the class and use the shortcut
ctrl + alt + 7.
That’s all folks!
I hope this article helped you on the way for mastering PhpStorm. They are the shortcuts I use everyday.
If you have other handy trick don’t hesitate to share them in the comment!
A bonus for the courageous developers who read my whole article: if you want to comment quickly a line or a block of text, just select the text and use
ctrl + / and
ctrl + shift + / respectively.
You can as well use the same shortcuts to uncomment blocks of code.
Now I am waiting for your own advices how to use this IDE more efficiently in the comment!