For years I was a happy Sublime Text user for my development needs. Everyone kept mentioning that PhpStorm is what you should use for development as it would help you a lot, and save a lot of time. Every year or so, I gave it a try, and soon gave up. It was just too bloated, too slow, and too Java looking. Maybe a lot of things changed, or maybe my approach to it changed, but I'm using PhpStorm for almost a year (at the time of writing) for development, and I just can't think about going back to use something else. This article is a bunch of tips which I think would have helped me in starting to use it earlier, and think it could be useful for others.
Keep in mind that it's based for OSX, there might be slight differences if you're using a different operating system. Some of the configurations are project based, meaning that you will have to make them for each project you work on.
Skip to any of the sections or continue reading:
- Changing PhpStorm Settings
- Back-up IDE Settings
- Set Up a New (Symfony) Project
- How to Configure Development Environment
- How to Configure Xdebug
- How to Make a 4 Editors Grid Layout
- How to Create Command Line Launcher
- Keyboard Shortcuts
A great starting point (you can familiarize yourself with the IDE without installing it) are the screencasts Be Awesome in PhpStorm by Laracasts and Lean and Mean Dev with PhpStorm (for Symfony) by Knp University. Both of them will inform you how to configure your IDE, how to navigate in it, and how to use all/most of the tools provided by it to make your development easier. Some of the topics overlap, but I would still suggest to check out both of them. You might skip Knp University screencast if you don't do Symfony development as it's more focused on it.
Check the download page for the latest information about installing. Everyone has their own installation preferences making it pointless providing all of them in an article like this. Personally, I use OSX with
brew, so for me installation is running install command in terminal:
brew cask install phpstorm
Changing PhpStorm Settings
You can change the settings of PhpStorm my making changes to
*.vmoptions files. You should not make changes to the original files. If you want to make changes to them, copy the file to a directory defined by your operating system.
The easier way is to use
Help | Edit Custom Properties, or
Help | Edit Custom VM Options options from the main menu of launched IDE. This will create an empty file, or open an existing one for you to edit.
You can read more about about this in Tuning PhpStorm help section.
Fix a Warning of Case Sensitive File System in OSX
If you use OSX and your file system is case sensitive you will get warning notification with and URL providing more information about it. I personally don't think that page is providing much information as there are multiple people providing similar solutions, and multiple people saying that they worked/not-worked for them. It provides more confusion that solves anything.
The simplest solution is to choose
Help | Edit Custom Properties (or edit your
idea.properties file), and put
idea.case.sensitive.fs=true in it. You will have to do this every time you update/install PhpStorm.
PS: I'm still not sure why that warning notification can't have a button "Yes I use case sensitive file system", which after clicking would just add that line to properties file.
Change CPU usage for indexing
One annoying thing you might run when opening PhpStorm is that it will slow your machine to the crawl because it's indexing all the files. Personally I'm more interested in the machine which is performing rather than the one which finishes the task faster.
Help | Edit Custom VM Options, and put
-Djava.util.concurrent.ForkJoinPool.common.parallelism=2 in it.
Disable Staging Created/Deleted Files
Version Control is a good example of IDE trying to do everything, and one of things I would rather do using external tools. You could disable it, but one thing I like it for is visual reminder (different file color, color blocks near line numbers) of what files have changed since last commit.
To disable automatic staging of files go to
Preferences | Version Control | Confirmation, choose:
Do not addfor
When files are createdoption
Do not removefor
When files are deletedoption
Enable Auto-Import of PHP Namespaces
To make IDE automatically import PHP namespaces, add
use statements, and complete short class names on the fly when typing go to
Preferences | Editor | General | Auto import, make sure that options
Enable auto-import in file scope, and
Enable auto-import in namespace scope are enabled.
Improve Visual Feedback
To keep the mind on important things the developers often expect the tools to provide visual feedback when something is wrong (or possible issue). The following settings ensure that it will be easier to spot possible issues, improve readability, and keep code clean.
Preferences | Editor | General:
- enable option
Ensure line feed at file end on Save
- enable option
Preferences | Editor | General | Appearance:
- enable option
Show line numbers
- enable option
- enable option
Preferences | Editor | General | Editor Tabs:
- enable option
Mark modified tabs with asterisk
- enable option
Preferences | Editor | Code Style:
- set option
Right margin (columns)to
- set option
Surround Selection on Typing Wrapping Character
If you want selected text to be surrounded with associated symbol when pressing any one of "
"" rather than replaced with that symbol go to
Preferences | Editor | General | Smart Keys and enable
Surround selection on typing quote or brace option.
Line Comments at Beginning of the Code
Comment with Line Comment (
⌘/ keyboard shorcut) can be very useful. The only problem I find with it is that it adds line comment at the first column no matter at that indentation level your code is. This is a personal preference, but I prefer when line comments are right beside the code. Go to
Preferences | Editor | Code Style | PHP | Other, un-check
Line comment at first column, check
Add a space at comment start.
Back-up IDE Settings
You can back-up your IDE settings by including the settings directory to the application what does your back-ups. The settings are stored in
/Users/<username>/Library/Preferences/<product-name> directory. This directory will change depending on the user and version, for example my current settings are kept in
/Users/ifdattic/Library/Preferences/PhpStorm2016.2 directory. Just remember to update your back-up strategy after installing new IDE version.
Git based backup
Warning: I removed this after a day, as I assume this just messed up all of my keymaps (resetting them to default), and maybe even some other configurations. For the time being I don't trust it enough to use myself, proceed on your own.
Another method which I just found while writing this article is using
git repository, you can read more about this in this help page.
Just create a GitHub Repository (private repository works if you don't want to share your settings with others), and add it through
File | Settings Repository.... For the first time you will want to
Overwrite Remote to push your settings.
From documentation it appears that settings are synced when you perform a VCS action of
Update Project. If like me you don't use VCS actions in IDE, you can perform
Sync Settings action to sync your settings. The issue might be that you will forget to run that action.
Set Up a New (Symfony) Project
There are some configurations that you do when you start a new project to get better IDE support for it. This is based on Symfony project, but you can do similar configurations for any project.
var directories. To mark a directory right click on it, from menu choose
Mark Directory as, and then choose the type of mark. This will make sure they don't get in the way then you're looking for some file. Now, because you might still want to search for 3rd-party library files add the
vendor directory as a library root by going to
Preferences | Languages & Frameworks | PHP and adding the
vendor directory as
You will also want to mark
src directory as
Preferences | Languages & Frameworks | PHP | Symfony and enable the plugin by checking
Enable Plugin for this Project option. From the same window change
Path to urlGenerator.php and
Translation Root Path options if you're using a new Symfony directory structure.
Preferences | Languages & Frameworks | PHP to choose the
PHP language level and
Interpreter for current project.
Below is a list of plugins I found useful for improving my workflow.
- BashSupport add support for bash language (syntax highlighting, inspections, etc.)
- Dash add shortcut to access Dash from IDE
- gfm add markdown support
- Lines Sorter add support to sort selected lines (or whole file)
- PHP Advanced AutoComplete it extends the support of auto-completion
- PHP Annotations add PHP annotations support
- Php Inspections (EA Extended) it extends the inspections (Static Code Analysis)
- Pipe Table Formatter format pipe (
|) delimited tables. This is very useful when working with Behat, but later found that
⌘⌥L) can do that too (so not needed anymore for simple cases)
- Scratch allows to have temporary editor tabs. In IDE all the files must be on the file system, which can be a hassle if you just need something to jot your notes on, or for similar throw away actions
- Symfony add support for Symfony (dependency injection container, doctrine, twig, etc.)
Add Ruby Syntax Highlighting
I normally don't work with Ruby, but sometimes it's required to make changes to some Ruby file (like Vagrant configuration), and having syntax highlighting helps a lot. You can find the full answer on how to do it on this Stack Overflow answer.
In short you need to:
- Git clone Ruby.tmbundle
- Add that directory to
*.rbfiles are not recognized you might need to modify
How to Configure Development Environment
For most projects you will want to make changes to your development environment configuration. This will give you proper errors depending on PHP version, and interpreter for debugging.
To change PHP version used go to
Preferences | Languages & Frameworks | PHP, select your PHP version from
PHP language level drop down.
Then click the button with 3 dots near the
CLI Interpreter. In opened window click the
+ icon, and choose
From Vagrant, ... option. It will open
Configure Remote PHP Interpreter window where you need to choose
Vagrant option, the IDE should pick the configuration automatically. Press
OK, and then
Yes to connect to remote host. Enter the name for the interpreter, and press
OK when done.
How to Configure Xdebug
Read this in the "How to use Xdebug in PhpStorm article".
How to Make a 4 Editors Grid Layout
Most of the time 2 editors split horizontally/vertically is enough for good development workflow. If you have a screen estate, and need to modify multiple files a grid layout of 4 editors is helpful.
┌─┬─┐ │1│2│ ├─┼─┤ │3│4│ └─┴─┘
It's easy to split the current editor into 4 editors, but your initial split will define in what order the cursor moves when moving between panes using shortcut.
If you start with a
horizontal split, and when split both of them
vertically the cursor will move in order of
1 -> 2 -> 3 -> 4 when pressing the next split shortcut.
If you start with a
vertical split, and when split both of them
horizontally the cursor will move in order of
1 -> 3 -> 2 -> 4 when pressing the next split shortcut.
How to Create Command Line Launcher
Sometimes you might want to use PhpStorm from the command line (e.g., to compare some files, open a file/directory in it). This can be achieved by using a CLI script which PhpStorm can create for you automatically.
Tools | Create Command-line Launcher... which should open a prompt where you can enter the name, and location for a script. For example you can put something
/usr/local/bin/phpstorm. In that case if your CLI script would be
phpstorm, and you could open a current directory by running
phpstorm . in command line. Personally I like to name my script as
You might need to do this if you have multiple PhpStorm versions, or you have recently upgraded.
In my opinion Sublime Text made very good choices for keyboard shortcuts, and I think it was a big issue when trying to move PhpStorm. Great thing is that you have a lot of freedom when configuring your IDE. Press the
⌘, to open preferences (
Main menu | File | Preferences...) window, and when choose
Keymap. You can search for an action you want to do, or lookup by pressing the shortcut.
Below is a list (in no particular order) of shortcuts I found comfortable, and use most often. Please keep in mind that for personal preferences some combinations are not available, or reserved by global shortcut (e.g.,
⌘ plus number is for moving windows around on my machine). You might think that there are a lot of shortcuts missing from this list, the way I see it is that the more shortcuts you have to remember, the less you will remember. I try to remember those that provide most value, or are used most often, and for the rest just use it some other way (like through the
Find Action ⇧⌘P). Some actions for which I have not found a good shortcut are marked with
Preferences...; open up the preferences window
Find Action...; open up a prompt to execute action or option
File...; open up a prompt to find a file
File Structure; open up a prompt to display file structure (methods, variables, etc.)
Go To Line;
Declaration; go to the declaration of the element
Jump To Source;
Implementation(s); open up a prompt with the implementations of class/interface, good for navigation when trying to figure out code
Jump to Navigation Bar; open up a small horizontal bar to navigate the project, very useful for creating/deleting files
New... | Generate...; create a new file from navigation bar, or generate code from editor tab
Extend Selection; selects more of the code / text (stopping at scopes)
Shrink Selection; selects less of the code / text (stopping at scopes)
Reformat Code; reformats the code using your defined code style (selection or whole file), also reformats BDD feature file tables
Refactor This...; opens up a prompt with choices for reformating the code (move, copy, extract, etc.), options change depending on the context
Copy; works on selection, or current line if nothing selected
Paste; works on selection, or current line if nothing selected
Cut; works on selection, or current line if nothing selected
Delete; works on selection, or current line if nothing selected
Show Intention Actions; opens up a prompt for field initialization, class importing, etc. (very powerful for writing less code once you get used to it)
Add Selection for Next Occurrence; add next occurrence to selection
Split Vertically; split the editor (with current file in the new and old splits), can go indefinitely
Split Horizontally; split the editor (with current file in the new and old splits), can go indefinitely
Goto Next Splitter; move between splits
Goto Previous Splitter; move between splits
Change Splitter Orientation;
Select Next Tab;
Select Previous Tab;
Move To Opposite Group;
Open In Opposite Group; when you want to have different parts of the file open
Reopen Closed Tab;
Find in Path...; open up a prompt to search in whole project
Replace in Path...; open up a prompt to search and replace text in whole project
Expand; unfold code at cursor
Expand All; unfold all code in file
Collapse; fold code at cursor
Collapse All; fold all code in file
Move Statement Up; move whole part of statement (method, line, loop, etc.) up paying attention to code
Move Statement Down; move whole part of statement (method, line, loop, etc.) down paying attention to code
Listen For Debugger Connections; start/stop debug session, rarely use it as for me personally it's easier to use Menu Bar Search
Alfred workflow (by using
m start, or
Resume Program; to continue the execution after stopping at breakpoint during the debugging session
Search in Dash;
Other | Project; open the project sidebar
Editors Tabs | Close All;
Jump to Last Tool Window; workflow example: search for something in whole project, select the result you want in results window, then press
↩ to show that file, or
⌘↓ to put a cursor at that location, press this shortcut to select different result
Resume Program; useful when debugging to continue code execution (it was conflicting with
RightClick workflow, the fix was to change workflow to only work for
Scroll Up; change editor view without changing location of cursor
Scroll Down; change editor view without changing location of cursor
Useful, but seldom used
Toggle Case; switch between lowercase/uppercase, useful with Mac keyboard where Caps Lock key is dumb
Column Selection Mode; toggle between normal selection, and rectangular selection
Redo; I was more used to
⌘Y for redo
Paste from History...; open a prompt to choose content to paste
Find Usages; search where selected element is used through whole project
Insert Live Template...; open a prompt to insert live template
⌥C + ⌥A =>
New Scratch; start a new temporary file
⌥C + ⌥S =>
Open Scratch List; open a prompt with a list of temporary files
Symbol...; open up a prompt to find any symbol (methods, variables, etc.)
Search Everywhere; open up a prompt to search anything (class, option, method, etc.)
Recent files; open up a prompt with recent files
Manage Projects...; open up a prompt with recent projects
Compare with Clipboard;
Select In...; useful when you want to select current file in sidebar (rather than navigating to it manually)