If you are developing WordPress themes or plugins we have a must-try IDE for you – PhpStorm from JetBrains. Let’s look at specific features wordpress developers can use in order to increase their productivity.
PhpStorm is a cross-platform, lightweight and smart PHP IDE that deeply understands your code, provides smart code completion, quick navigation, on-the-fly error checking, unit-tests running, visual debugging and much more. However, it’s not only about PHP – you can work with HTML, JS, CSS and many other technologies easily without changing the environment you work at. There are a lot of features saving your time and energy – feel free to check at features page.
When it comes to WordPress plugins or themes development it’s extremely important to have intelligent tools in order to make development fast and painless. You can start using PhpStorm for WordPress just out-of-the box: it understands PHP by default and you just need to create a project from the directory, FTP or version control system (such as Subversion, Mercurial, Git, Perforce, CVS, TFS) – WordPress classes/functions will be loaded and hinted for you.
PhpStorm comes with cool built-in color coding scheme, however, if you want to change it just edit settings (File | Settings | Editor | Colors & Fonts) or check other themes here. IDE appearance can be adjusted in settings as well. There are also a lot of plugins in the repository you can easily download and use.
In order to understand how to work with IDE check online help.
Everything in PhpStorm is done within a project so that you can configure different projects corresponding to your needs. WordPress code hinting and code completion works from the very moment you have wp-includes folder in your project.
In order to make your work with IDE more productive check Keymap Reference and get acquainted with all the hotkeys you can use. All the hotkeys in PhpStorm Keymap can be changed at File | Settings | Keymap. For instance select the function you’re working with and press Ctrl+Alt+B (Cmd+B) in order to go to implementation. Hotkeys help you to navigate and act faster without using a mouse.
For WordPress developers PhpStorm can be completed with WordPress-specific features:
2. Use wpdb in order to expand WordPress properties in PhpStorm. This option will make work with built-in variables easier.
Check this screencast in order to get information about WordPress development in PhpStorm.
Debugging WordPress with PhpStorm
PhpStorm provides numerous options for debugging your PHP and WordPress code out-of-the-box, so you can:
- Inspect context-relevant local variables and user-defined watches, including arrays and complex objects, and edit values on the fly;
- Setup remote debugging for your server;
- Evaluate an expression in runtime;
- Debug a page in multiple sessions simultaneously;
- Keep a debugging session alive while moving between pages.
You can use our browser bookmarklets, Zend Toolbar or XDebug toolbar to initiate debugging directly from any page in a browser.
For instance, one of the easiest way to begin WordPress debugging with PhpStorm is using Xdebug (so you should have a web server with correctly installed Xdebug. Don’t forget to set the xdebug.remote_enable setting to 1. You can validate your installation using checker from xdebug.org). In order to prepare PhpStorm for listening just ‘Toggle the ‘PHP Listen debug connections’ button. After that you can set a breakpoint in your code.
In order to activate the debugger on the server you need to set the special GET/POST or COOKIE parameter. You can do it manually, but it is much more convenient to use one of the special tools such as browser toolbars or bookmarklets for that.
Try our bookmarklets generator and get bookmarklets which will work in any modern browser and allow you to start/stop a debugging session by controlling the Xdebug cookie.
Start a debug session in browser and reload the page. Switch to PhpStorm and set the initial path mappings by selecting the path to the local copy of the script that we are debugging. These paths are similar if you are editing files directly on the server.
On reaching the breakpoint the debugger suspends. Debug with pleasure!
In order to get familiar with Debug and Testing in PhpStorm check these links:
- PHPUnit Support
- Zero-configuration debugging with XDebug and PhpStorm
- Configuring PHP debugging in PhpStorm (manual configuration)
- Screencast Remote Debugging with PhpStorm and Xdebug
- Using PhpStorm for WordPress Debugging and Development