Site icon WP Smith

My Genesis Site: My Preferred Text Editor/IDE

PHPStorm by defenestr8me

Over the past 3 years I have tried a variety of editors and IDEs (Integrated Development Environment), including, but not limited to:

*Please note that I have a Windows machine, so Mac IDes (e.g., Coda, etc.) were not part of my evaluation though I have used Coda Lite on my iPad.

I have enjoyed each one for its particular nuances, and each IDE has its strengths and weaknesses. Each one comes with its preset shortcuts and some have the ability to change their shortcuts on a per user basis. Personally, I believe anyone can compare these editors and as many editors there are there could be winners, and there is always that one person who will go and create another editor because the "others just won't do what I need."

If you can afford it, I encourage you to do what I did and spend time whether it's a week, two weeks or an entire month (probably best) to determine which editor is the best fit for you. If you currently use an editor and you have gotten along fairly well, then there may not be a need to switch (unless it is vanilla Notepad).

However, if any of you do any PHP development, almost hands-down across personal, professional, and enterprises, PHPStorm is the recognized international leader for development and integrations. It really does make life simpler.

For me, I finally tried PHPStorm and when I did, I was blown away. After doing Grunt, Gulp, and Phing to automate my workflow struggling with it from a "purist" point-of-view, when I did these things on PHPStorm, I was up and running in no time at all asking myself, "Why didn't I try this sooner!?" So let me outline the benefits of PHPStorm at a high level and highlight a couple of those benefits in more detail. Please note this will only scratch the surface of the benefits of using PHPStorm.

Benefits of PHPStorm

As a WordPress developer, I only care about the benefits of an IDE as it pertains to helping me develop inside of WordPress. So what does PHPStorm offer? It offers a great deal actually.

  1. PHPDoc support
  2. Coding style support, built-in PSR1/PSR2, Symfony2, Zend, and Drupal compliant code formatting
  3. Code Analysis: Coverage, Mess Detection, Copy-Paste, Reformatting according to WordPress Coding Standards
  4. PHP refactorings and code (re)arranger
  5. Visual debugger for PHP applications with debugger configuration validation, PHPUnit with code coverage, and Profiler integration
  6. Cutting-edge web development technologies are supported including HTML5, CSS, Sass, SCSS, Less, CoffeeScript, TypeScript, Dart, ECMAScript Harmony, Jade templates, Zen Coding, Emmet, AngularJS, and of course JavaScript.
  7. Includes all the functionality of WebStorm (HTML/CSS Editor, JavaScript Editor) and adds full-fledged support for PHP and Databases/SQL.
  8. Supports PHP 5.3, 5.4, 5.5, 5.6 & 7.0 (partial), including and all the syntax improvements
  9. Vagrant integration, Composer support, Built-in REST Client & SSH Console with remote tools, Command Line Tools, Google App Engine for PHP support, Remote PHP interpreters, Behat
  10. Version Control Systems integration with unified UI
  11. Integration with issue trackers

That's great, so what does all that mean?

PHPDoc Support

So if I have a function:

function wps_is_debug() {
return ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) );
}
view raw functions1.php hosted with ❤ by GitHub

As soon as I type /** and press ENTER, PHPStorm gives me:

/**
* @return bool
*/
view raw header1.php hosted with ❤ by GitHub

If I were to type /* and press ENTER, PHPStorm gives me:

/*
*
*/
view raw header2.php hosted with ❤ by GitHub

Now all I need to do is to enter the description and more details.

Besides the return, PHPStorm auto-populates the parameters. So if I have a function:

}
if ( !function_exists( 'plugins_api' ) ) {
view raw functions2.php hosted with ❤ by GitHub

As soon as I type /** and press ENTER, PHPStorm gives me:

/**
* @param $plugin
*
* @return object
*/
view raw header3.php hosted with ❤ by GitHub

WordPress Coding Standards

Reformatting

Let's say you inherited someone's functions file that had something like this:

function wps_get_plugin_info($plugin) {
static $plugins=array();
if ($plugin!='myplugin')
return false;
if (isset($plugins[$plugin]))
return $plugins[$plugin];
if ( !function_exists( 'plugins_api' ) )
require_once(ABSPATH.'/wp-admin/includes/plugin-install.php');
$info=plugins_api('plugin_information',array('slug'=>$plugin));
$plugins[$plugin]=$info;
return $info;
}
view raw functions3.php hosted with ❤ by GitHub

In PHPStorm, if you go to Code > Format Code, it will reformat the code to this:

function wps_get_plugin_info( $plugin ) {
static $plugins = array();
if ( $plugin != 'myplugin' ) {
return false;
}
if ( isset( $plugins[ $plugin ] ) ) {
return $plugins[ $plugin ];
}
if ( ! function_exists( 'plugins_api' ) ) {
require_once( ABSPATH . '/wp-admin/includes/plugin-install.php' );
}
$info = plugins_api( 'plugin_information', array( 'slug' => $plugin ) );
$plugins[ $plugin ] = $info;
return $info;
}

Notice that PHPStorm automatically added {braces} to all if-statements. It aligned all the equal signs (=). And it added all the necessary whitespace whether that's 2 spaces per tab, 4 spaces per tab, or just tabs.

Deprecated Functions


PHPStorm is intelligent enough when you are editing the project (someone else's project right?), functions that have been deprecated will have a strike-through the function name.

Git Integration

I simply love the Git integration of PHPStorm. After the setup, the Git integration is fairly seemless. Whenever I create a new file, it asks me whether I want to add it to the project's version control. I can use shortcuts like Ctrl+K to commit and Ctrl+Shift+K to push. Whenever I commit, PHPStorm can do code analysis requesting that I fix issues before I commit the changes. All these small things add up to a lot of time over the period of a week.

Deployment Options

Besides integration into Git and implicit any Git Deployments, PHPStorm has a built-in SSH/sFTP engine to deploy code to any server. As soon as the file changes and is saved, it can automatically deploy to whatever your preferred server is. And you can setup multiple deployments.

Conclusion

Do you use PHPStorm? What did you like and not like? What is your most favorite feature of PHPStorm? If you don't use PHPStorm, why not?