Level up with PHPStorm
When people classically think of somebody writing code, they often think of somebody in a black hoody typing into what looks like VIM in black and green. Now we all love a bit of VIM, but it's not necessarily the ideal tool to use for large projects. There is a whole world of functionality that opens up when your editor can not only edit your code but understand it, and that's why we use PHPStorm.
Before I go any further, I'll note that there are no affiliate links or magic profits for us to get by recommending PHPStorm - we really do just like it a lot!
We in the Coventry office were quick to get going with PHPStorm, and made it our de-facto IDE almost straight away. It took a few years to prise the Bristol guys off Sublime, but once converted they were very happy indeed!
Key things that are possible with PHPStorm:
- Understand your code! Navigate between classes, services and templates with ease, because PHPStorm literally understands your code.
- Write your code faster! Automatic completion for Drupal hooks and other boilerplate code gets you going quicker.
- Tidier code! PHPStorm can automatically tidy your code according to standards that you can set - and Drupal code standards are just three clicks away!
- Debug your code! Press pause on execution, inspect variables, change variables, see exactly what's going on.
- Easy version control! PHPStorm has integrated tools for Git, SVN, Mercurial, etc. that mean you can work all within one window.
- Tests! You can run and debug your code tests from within PHPStorm just like any other code.
- Deployments! Set up manual and automatic deployments of code via FTP.
I could spend ages extolling the virtues of a good IDE over a 'dumb' text editor, but instead I'll simply recommend you go give it a try. Your world may be changed forever!
PHPStorm has a host of plugins available that add vital functionality. A number of these are worth a mention, because once you have them you realise how much easier life can be.
Plugins for Drupal 8
If you're developing on Drupal 8, make sure you have these plugins. You won't regret this for a moment.
- Drupal Support
- Drupal Symfony Bridge
- Symfony Plugin
- Twig support
- PHP Annotations
Plugins for other things
- Zero Width Characters Locator - Don't waste hours of your afternoon being confused by invisible characters appearing in your code / live site / deployment - have them pointed out to you. (This is a ComputerMinds favourite! Why are there so many invisible characters in StackOverflow posts??)
- Lines sorter - Select a bunch of lines and sort them alphabetically. A handy plugin to have around.
- Dash - Dash is a great (OSX) tool for getting hold of documentation fast. Integrate it with your editor and POW! - you're flying.
- Power Mode II - Visual confirmation of just how fast and awesomely and powerfully you're writing code - have sparks flying, fireworks launching, the very ground shaking, all as you type your awesome code. The more/faster you type, the more the sparks fly! This plugin is hilarious fun just to play with for a few hours :) Then it gets a bit annoying so you turn it off... but it's well worth it!
Too many plugins?
It's really tempting to just go and turn on ALL of the plugins, to feel like you have the entire world's functionality at your fingertips. This, as we have discovered, becomes rather detrimental to PHPStorm's performance. So we recommend you occasionally check which plugins you have enabled and whittle them down a bit if you can. No point having plugins enabled for file types you never work with, for example.
PHPStorm lets you create 'Scopes', which are defined subsections of your code directory. You can then have PHPStorm search or perform actions on those scopes. The best example would be searching a 'Custom code' scope, which might include your custom code directories and exclude Drupal core, and thus go a little faster.
Exclude from index
PHPStorm likes to spend a LOT of time indexing. It checks your work for changes every few moments so that it can keep up with what's going on, but there are things that can make this unnecessarily slow:
- Large directories - Large directories take a long time to index and a lot of effort to keep up with. Exclude them if you're not going to need or work with their contents. A good example would be the Drupal files directory; definitely exclude that!
- Compiled assets - Unless you need PHPStorm to be doing clever things with the compiled sprites from your theme, exclude them and any other compiled assets you're not realistically going to want PHPStorm to have indexed.
- Node - Exclude any node directories, as they're enormous and you're not going to need anything from them.
Clicking the progress bar at the bottom of the window will allow you to spot directories that are taking a long time to index.