Comparing Things in PhpStorm III

Comparing entire directories in PhpStorm


In the last article, we looked at comparing files in PhpStorm. In this final article of the series, we'll look at how to compare whole directories.

MODX logo

Comparing Directories

This feature has saved me a ton of time. When I work on the MyComponent extra, I can't use it to build itself because the version I use for development has a number of features that shouldn't be in the distribution version. That means I have to have two separate copies of the extra. Changes in the development copy have to be moved to the build copy but it's a while between releases and I need to make sure that all the changes (but not the custom development files) get transferred to the build copy.

I used to copy files as soon as I edited them, but it was a pain to interrupt my work and I was never sure if I remember to get them all. Fortunately, there's a much easier way. I can now wait until I'm ready to release a new version and do them all.

In PhpStorm, I select the root folder from each copy of the extra with Ctrl-click, then I right-click and select "Compare Directories," or press Ctrl-d. Now I have a window similar to the file diff window, but showing a list of files instead of code differences. The ones from the first directory I click on are on the left. I have it set to hide files that are the same in both directories. There are a series of symbols in the center between the two file lists. Files that are in the left directory but not in the right have a green right-arrow there. Files in the right directory but not in the left have the same arrow but pointing the other way. I can copy files either way. If the file is an image, clicking on it will show the image in the lower panel.

Files that exist in both directories, but are different, have a red, not-equals symbol in the middle. If I click on that line, a new window opens up showing the differences between the two files. It's just like the file compare window and I can easily move specific changes either way. More often, I just check out the changes and copy the whole file from the development copy to the build copy with a couple of clicks.



What if the second directory is not in the project? It works just like comparing files. I select one directory and press Ctrl-d. A window pops up showing a tree for my whole drive, but showing only folders. I navigate to the second directory and select it. Now I'm looking at the file differences between the two directories.

This is a fun feature to use when a new version of MODX comes out. I create a new project containing the new version (no need to install it). By doing a directory compare on the two root directories, I can easily see which files have been added or removed, which files have been changed, and what the changes are.




Wrapping Up

You have to pay for PhpStorm, but it has saved me countless hours of frustration and made coding infinitely more pleasant. This article contains just a tiny fraction of the reasons why you need it if you write code (including CSS and HTML).

If you want continuous updates of PhpStorm, you have to pay each year, but you're free to keep using your current version forever without paying anything after the initial purchase. PhpStorm is often offered at a significant discount before school starts in the fall. If you want a copy, keep an eye on the price.



Coming Up

In the next article, we'll look at how to handle MODX System Setting lexicon strings in transport packages (trust me, it's weird).



Looking for high-quality, MODX-friendly hosting? As of May 2016, Bob's Guides is hosted at A2 hosting. (More information in the box below.)



Comments (0)


Please login to comment.

  (Login)