How to Develop WordPress With PhpStorm
A few weeks ago in PhpStorm 8 (available in the program early access / Early Access Program) has added support for popular CMS WordPress. Fresh build PhpStorm 8 EAP can download for free right now so that all the training described in this material is already possible to try.Â In this post we will talk about the most important features included in the WordPress support in PhpStorm. Currently, support includes:
- PhpStorm integration with WordPress for existing projects and new plug-ins;
- setting the working environment for the development of a WordPress;
- Programming style setup WordPress and following them;
- support hooks (including completion of parameters recording functions, navigation functions by
- registering hooks, hooks to the challenges, and other functions);
- search a documentation on WordPress.org directly from the editor;
- integration with command line tools WordPress WP-CLI.
Integration with WordPress for existing projects and new plug-ins
Enabling Integration in existing projects
If the project that you are doing the work, is recognized as a plugin for WordPress, you will be automatically prompted to enable WordPress project. You need to enter / select the path to the installation folder WordPress ( WordPress Installation Path – the root installation directory WordPress, which houses folders wp- admin and WP-includes ). Integration with WordPress for the project can be enabled or disabled in the Settings | WordPress | WordPress Enable Integration.
Create a new plug-in for WordPress
New WordPress-plugin can be created with the initial screen ( Welcome ) or via File | New Project. Select the type of project WordPress Plugin and after clicking OK, enter / select the path to install WordPress ( WordPress Installation Path ). Beginner plugin file in the project will be created automatically by the standard template file ( plugin-name.php with the corresponding meta-information about the plugin).
Setting up your development environment for WordPress
Regardless of the method of activation of integration with WordPress (by creating a new plugin or enable support for the existing project), IDE configuration check for compliance with the best practices of development under WordPress. If the current configuration can be improved, there will be pop-up proposals for auto configuration development environment. All offers PhpStorm within integration with WordPress can also be viewed in the Event Log. PhpStorm enabled WordPress offers the following options auto configuration development environment:
- configuration Include Path (in the case where the directory wp-content and / or your plugin is out of installing WordPress);
- Configuration Content Root (when the directory wp-content and your plugin is inside the installation WordPress);
- Switching to Programming style WordPress (Programming style can be changed in the settings Settings | Code Style | PHP . Programming style WordPress can be applied by selecting Set from … | Predefined Style | WordPress ).
Support hooks WordPress (WordPress Hooks)
Autocomplete for function parameters such as WordPress and Action Filter (autocompletion hooks)
All hooks that are declared in the core WordPress and connecting modules are indexed editor PhpStorm When the integration with WordPress, which makes it possible to display the names of hooks in the code completion (for the standard action Ctrl + Space ) for the parameters of the standard functions and action filter (for example, add_action and add_filter ).
Navigation from registration hooks (type functions action and filter) to the challenges of hooks
Navigation can be performed from the places of registration hooks WordPress (using recording functions, such as add_action and add_filter ) to place a call to hook (hook invocations) by clicking on the icon on the left navigation field editor:
Callback registration with hook
The transition from the ad function / method specified by the second parameter functions registration hooks Actions / filter ( add_action and add_filter ), produced by the action Ctrl + Click ( CMD-Click on Mac OS X) or Ctrl + B ( CMD-B on Mac OS X) .
Navigate to Symbol … for hooks
Using the Navigate | Symbol … ( Ctrl + Alt + Shift + N on Windows / Linux, CMD-ALT-O on Mac OS X), you can search for calls hooks and easily navigate to them. For the same purpose, you can use the action Search Everywhere ( Double-Shift ). Realized and other functions, provides support for hooks, such as Find Usages (search uses).
Search WordPress.org documentation directly from the editor
The transition to the documentation on the official WordPress resourceÂ WordPress.org available directly from PhpStorm using text search. Simply select the item code (text, function and so on. D.) To be found in the documentation, and select an action Search on WordPress.org from the context menu of the editor. This will open your browser, the default, the search results on the documentation WordPress.
Integration with command line tools WordPress WP-CLI
WP-CLI – a set of command line tools for the control of WordPress. You can update plugins implement multi-site installation and more (all without the use of a browser). We recommend installing the command line tools WordPress WP-CLI, follow the instructions on the official website (by downloading PHAR-pack) or by using the Composer directly from PhpStorm ( package cli-WP / WP-cli ). For more information about the configuration of WP-CLI and many other features included in the WordPress support in PhpStorm, can be found in full training on developing a WordPress using PhpStorm . You can get acquainted with the already known our tasks and bugs on integration with WordPress. We will welcome any comments on the current support in WordPress PhpStorm and other subsystems of our IDE. Download the latest build PhpStorm 8 EAP-enabled WordPress and many other innovations now! Program with pleasure!