PhpStorm – Review and Give Away
It’s said the tool doesn’t make the craft – a carpenter can drive a nail into a wooden plank using a hammer, a rock, another plank, or his forehead, but he’ll rarely choose anything other than the hammer. Some of our foreheads may have gone hard with constant hammering while programming, but that doesn’t mean its a better tool than the never before used hammer. Ok, enough analogies, I’m talking about using a text editor versus using a full-fledged PHP-dedicated project-oriented IDE for PHP application development. Both will get the job done, but productivity-wise, one is obviously a better choice than the other.
PhpStorm is a Java-based IDE developed by Jetbrains, derived from a master multi-programming-language IDE called IntelliJ IDEA. It’s a stripped down version of IntelliJ with added PHP support – something IntelliJ needs to have manually enabled via a plugin.
Now, this wouldn’t be a good review if I didn’t mention some downsides, but luckily these are few and far between and, as you’ll see below, aren’t show-stoppers. Let’s get them out of the way first.
First and foremost, PhpStorm is built on Java. Java is a dinosaur language and the VM which needs to spin up to execute Java apps is one of the greatest memory and CPU hogs – especially when working in an OSX environment. Coupled with the IDE’s rich functionality, this resource demand might prove to be too much for weaker machines. Using Java comes with a big perk though – PhpStorm is fast. Blazing fast.
Furthermore, PhpStorm is a project-based IDE, which means there’s no simply editing just one file. You need to define a project and tell the IDE which files are included in it. This is a professional IDE designed for heavy coders who develop large applications and professional platforms. It emphasizes speed, productivity, and ease of access to the entire project, and as such, offers no actual support for individual PHP file editing in the traditional sense. Certainly, you can edit a PHP file, but it’ll get opened under the project you have opened at that time. And new projects must be opened in a new window – there’s only one IDE instance per open project.
But while I mentioned being built on Java as a downside, it’s also a huge-advantage. It lets us use the IDE on every development platform we own. This alone is worth looking at as a deciding factor in the purchase, as it allows you to carry your development environment with you. If you have a specific set of rules for every project, if you have coding styles and enforce PSR standards, if you have include paths that are identical across platforms but are a pain to set up over and over again, all you need to do is load the configuration from the originally configured PhpStorm and you’re good to go.
The second downside also doubles as an advantage. The IDE being strictly project-oriented means it indexes your entire project (all of your include_path as well if set), and offers full-fledged autocompletion with documentation for all the classes bound to your project, namespaces and all. You can exclude certain files and folders if you wish, but the gist of the matter is that one IDE instance handles one IDE project – the resources of one instance are dedicated to fast intellisense and code scanning of that project. Naturally, the clipboard is cross-instance compatible, so copying files or code snippets from one instance to the other is a breeze, whether you do it via the clipboard or just drag and drop across windows.
PhpStorm 4+ supports the latest PHP version, including 5.4. There’s trait support, short array syntax, and all the other candy. If you’re developing a 5.3 project but would like to use 5.4 on new projects, configuring the IDE to do so is a walk in the park – you can set the actual interpreter version in the project configuration. If you accidentally use the short array syntax in the 5.3. project, the IDE will warn you accordingly.
Another useful feature is smart refactoring; you can rename a file and have its include statements altered automatically across the entire project. You can refactor a global variable and have it changed in every file which uses it. You can refactor a property and see it and its accessors change without further effort. You can even refactor an entire PHP namespace and have it change across all classes. Imagine how much time this saves when dealing with 10k+ file projects.
Large IDEs can be convoluted and complex, but PHPStorm eases you into its functionality in two ways: 1) Quick Tips that are actually practical will appear on every startup, unless you decide not to show them anymore. I’ve learned around 50% of all commands I know and use from these tips. 2) If you can’t find an IDE option in the menus, hitting Ctrl + Shift + A will open a command browser in which you can type out the IDE command you want to do. Want to git push the changes? Ctrl + Shift + A, and type “Push”. Forgot the shortcut for move line up/down? Just Ctrl + Shift + A and type “move line”. The shortcut will be displayed in the list. This isn’t your average autocomplete either – this is near-instant.
There’s also a built-in graphical diff tool which highlights differences in a readable manner allowing you to visually compare the changes and seamlessly transfer updates from one file to another with the click of a button. If a conflict occurred, just hitting resolve will delete the conflict resolution files after the user syncs them up.
The IDE also has excellent plugin functionality and a vibrant community around it. It is, essentially, built as a bare-bones application and all the functionality is plugged in. This lets you disable the plugins you don’t need (like the enabled-by-default CVS and SVN if you only use Git) to conserve resources, and lets you expand the IDE adding new functionality you feel is missing. To look up some plugins, see http://plugins.intellij.net/?webide
Here’s some more gems:
- Clicking the closing brace of a block that begins off-screen will display the entire starting line of said block in the top editor gutter. So if you forget the arguments a function consumes, there’s no need to scroll – just select its ending brace and the starting line will appear on the IDE frame.
- Open any file with CTRL + Shift + N, or class with CTRL + N, instantly. No scrolling through directory trees, no loading or searching. This is extra handy when you have many files/classes in your project.
- Got some messy code from other developers which you can’t look at unless it’s at least in PSR-1? Just run the code auto-format with CTRL+ALT+L on the files, blocks of code, or even entire folders to clean it up according to the coding style du jour.
- Any undefined namespaces, redeclared classes, syntax errors and disrespected type hints will glow red. They will be highlighted in the right editor gutter and in the code itself. PHPStorm is your pair programmer – it helps you avoid silly bugs before you even make them!
- Keyboard shortcuts like “duplicate line”, “move line up / down” and live templates which let you create aliases for entire blocks of parametrized code will speed up your development and editor navigation. As an example, have a look at a couple videos and notice the speed of the developer as he uses autocomplete, live templates and various other WebStorm shortcuts to speed up his workflow.
There are loads of other features – I can only recommend you download the 30-day trial and give it a go. If it feels intimidating at first, stick with it and within a day or two you’ll be working it like a pro.
Free Give Away
Many people oppose transitioning to PhpStorm with the argument: “Netbeans has all that and it’s free.” While I won’t argue that Netbeans does indeed have the majority of features PHPStorm offers (although not all of them), even if they had identical features, interfaces and commands, the speed increase alone is worth the price. Also, NetBeans belongs to Oracle as of 2010 who have done little in the past couple years to bring the IDE up to speed.
Also important is the fact that the company making PhpStorm is approachable and friendly – the software they make is maintained, built, and sold by people you can actually reach. Most people figure: “I don’t care if they burn puppies or have supervillainous plans, I like their product” (which is essentially why Apple products get sales). But Jetbrains is open to suggestions, they give discounts for good causes, they extend trial periods if you ask them to, they will even provide you with a free Open Source license if you’re the main committer of an Open Source project!
It is in this friendly and generous spirit that Jetbrains, in partnership with SitePoint, is giving out PhpStorm licenses and hard copies of PHPMaster: Create Cutting Edge Code!
To be eligible for the give away, either 1) download the IDE, test it out, and post a comment below in which you name your favorite feature, or 2) share this article on Twitter with the hashtag #phpmaster, all by August 22nd. Three winners will be chosen at random shortly thereafter. Comment winners will be notified by email (be sure to provide a valid email address in the contact-form!) and Twitter winners by direct-message.
- 1st Prize: A PhpStorm license and a hard copy of PHPMaster: Create Cutting-Edge Code
- 2nd Prize: A PhpStorm license
- 3rd Prize: A hard copy of PHPMaster: Create Cutting-Edge Code
Good luck, and happy coding!