WordPress Support in PhpStorm 8 EAP
We are glad to announce availability of WordPress plugin (providing a bunch of WordPress-specific features) bundled with PhpStorm from yesterday’s PhpStorm 8 EAP 136.1255, you can download and test it right now.
Please refer to a full tutorial on WordPress Development using PhpStorm to get an insight on how to get started with new features.
Current WordPress support includes:
- WordPress integration in PhpStorm for new plugins (with plugin skeleton) and existing projects
- Development environment configuration for WordPress
- WordPress code style
- Hooks support (Including completion for registration functions parameters, navigation from hook registration functions to hook invocation, callbacks from hook registration, and other hooks-related features)
- Search on WordPress.org right from the editor
- WordPress command line tool WP-CLI integration
Enabling WordPress Integration in an Existing PhpStorm Project, or Creating a New WordPress Plugin
Enabling WordPress Integration in an Existing PhpStorm Project
When the project you’re working on is recognized as a WordPress Plugin, you will be offered to enable support for WordPress automatically.
You need to provide WordPress Installation Path (root folder of your WordPress Installation, directory should contain wp-admin and wp-includes subdirectories).
Creating a New WordPress Plugin
A new WordPress plugin can be created from the Welcome screen or by selecting File | New Project. Project type should be set to WordPress Plugin. After clicking OK you need to provide WordPress Installation Path.
Initial plugin file in the project will be created automatically (plugin-name.php with proper meta information skeleton).
Development Environment Configuration
Whether you enable WordPress integration in an existing PhpStorm project or create a new WordPress plugin, the IDE checks if the development environment is configured properly for WordPress development. If the configuration does not meet the requirements, pop-ups with a fix suggestion will appear, as well as events in the Event Log.
Following development environment configuration help is provided by PhpStorm with WordPress Support:
- Include Path Configuration (wp-content folder and/or plugin you are working on are OUTSIDE of WordPress installation)
- Content Root Configuration (wp-content folder and plugin you are working on are INSIDE WordPress installation)
- WordPress Code Style (Code Style can always be re-configured in Settings | Code Style | PHP. WordPress-specific code style can be applied with Set from… | Predefined Style | WordPress)
WordPress Hooks Support
Completion for WordPress Action and Filter functions parameters (hooks completion)
Any hooks declared in WordPress core and included plugins are indexed by the IDE, and hook names become available in code completion with Ctrl+Space for standard action and filter functions parameters (add_action and add_filter).
Navigation from Action and Filter functions (hook registration) to hook invocation
From WordPress hook registration (with add_action and add_filter functions) you can navigate to hook invocations with a navigate icon on the editor gutter:
Callbacks from Hook Registration
Going to declaration of function/method specified as the second parameter of actions/filters hook registration functions (add_action and add_filter) can be performed with Ctrl+Click (CMD-Click on Mac OS X) or Ctrl+B (CMD-B on Mac OS X).
Navigate to Symbol… for Hooks
With Navigate | Symbol… (Ctrl+Alt+Shift+N on Windows/Linux, CMD-ALT-O on Mac OS X) you can search for hook invocations and easily navigate to them. Similar results can be achieved with Search Everywhere (Double-Shift).
There are more hooks-related features available, for example Find Usages.
WordPress Command Line Tool WP-CLI Integration
WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
We recommend installing WordPress Command Line Tool WP-CLI, either by following the official website instructions (via downloadable PHAR package) or with Composer right in PhpStorm (package wp-cli/wp-cli). Refer to this tutorial for more information about using Composer in PhpStorm.
Configuration of WP-CLI and many other features are described in detail in WordPress Development using PhpStorm tutorial.
Please browse through already known WordPress-related issues in our issue tracker.
Download latest PhpStorm 8 EAP for your platform from project EAP page and please report any bugs and feature request to our Issue Tracker.
Develop with pleasure!
-JetBrains PhpStorm Team