See also the How we use PhpStorm for WordPress Development from Delicious Brains.
When you start working with PhpStorm you should create a new project. The PhpStorm project should be rooted in the site project you’re working on, usually where the
.git directory is located; on VIP projects, you can create the PhpStorm project at the root of the VIP Quickstart repo, so one PhpStorm project would be used for multiple VIP sites and clients.
When you create a PhpStorm project, you’ll see a
.idea directory created. Add this to your Git repo’s
PhpStorm provides a
pstorm command line tool. You install this via Tools > Create Command-line Launcher…. Once installed, you can open the
.idea PhpStorm project from the current directory via:
If the project doesn’t already exist, PhpStorm will create the project (the
.idea directory) in the current working directory.
- Command-Shift-A: Bring up a quick search for all commands (so you don’t need to know the keyboard shortcut), such as “To tabs” to convert indents to tabs.
- Command-Option-O: Open a search box for finding any symbol in the project, such as variable name, function name, class name, WP filter/action hooks, etc.
- Command-Shift-O: Open search box for all files in the project to quickly open.
- Command-O: Open search box for PHP classes.
- Command-Shift-Backspace: Navigate back to the previous change you made.
- Command-[ & Command-]: Navigate to previous location, or navigate forward.
- Ctrl-Space: Bring up a list of autocomplete options.
- Command-B: Jump to source declaration for the function, variable, or other construct.
- Command-P: Show list of parameters in the current argument list.
There is a WordPress code style that is bundled with PhpStorm. This will help auto-format your PHP and JS code as you write it to adhere with WordPress Coding Standards. To select the WordPress code styles for the current project, go to preferences and Editor > Code Style and then select “WordPress” in the dropdown.
- BashSupport — add syntax highlighting and code intelligence to Bash scripts
Navigate to the Version Control pane in the preferences to see the (nested) repos that PhpStorm discovered in your project. For non-VIP projects, this may only be the root repo. But for VIP projects, there will be quite a few, for instance:
When PhpStorm recognizes a file as being part of a repo, it will show in the left margin that it is modified (blue), added (green), or deleted (arrow):
Clicking on the indicator will bring up a menu that allows you to see what was there before the change. You can navigate to the next/previous change, revert the change, open the diff in a viewer, or copy the initial value to the clipboard.
Languages & Frameworks
- Installing PHP_CodeSniffer
Add your local clone of WP-CLI to your PHP include path:
And enable WordPress integration, pointing to your source on your local machine: