PhpStorm logo - it's got purple and pink and it's very pretty. Also happy new year!

PhpStorm – An IDE Not Just for PHP – by William Reveal

Hi Allison and fellow Castaways, long-time listener to the Podfeet family of podcasts and even longer-time developer. As is typical of me, I have been in stealth mode, supporting you through your product links. I thought I might throw in my 2 cents regarding a handy tool for coding, an IDE called PhpStorm by Jet Brains. An IDE is an integrated development environment and can be real handy.

My Problem to be Solved

I had a problem caused by another problem. My web server out in the cloud was getting old, cranky, and needing to be retired, like me. So I spun up a brand new server without all the kruft. I decided to simplify my life by using just version 8 of PHP instead of running three different versions: 5, 7, and 8. That sounds great and all, but PHP 8 does break older code. One of my sites is based on my own library of PHP code which can be traced all the way back to code I wrote in PHP version 3.

It went through rewrites for each successive version, including a brief dalliance with the never-released version 6. So, yeah, the PHP code has a lot of kruft in it, just like me. And that is the problem, code that was written correctly in version 5 and acceptable in version 7 suddenly didn’t work at all in PHP 8.

Looking at the programs running on my Mac right now sits BBEdit (which is always running), CodeKit for Sass, SourceTree for git, iTerm for command line where I use Vi (well, Vim), git, sass, ESLint, composer, php, shell scripts, etc, etc, ad nauseum.

An IDE Makes This Easier

The crazy part is that I don’t need any of them running technically, not when I have an IDE (Integrated Development Environment). After a long search several years ago, I settled on PhpStorm by Jet Brains.

An integrated development environment means it incorporates all the functionality of all those tools I mentioned, adds a bunch more capabilities, and provides a single window where I can do it all. It is an integration tool, meaning certain capabilities do need to be installed separately on your Mac through tools like XCode, Homebrew, or MAMP to get the full experience. But PhpStorm does provide most of the tools that you need on a daily basis.

Starting with PhpStorm

Now, I needed to fix my code to get my website back up so I did the smart thing… I stared at the code, tearing my hair out, not knowing where to start or why it didn’t work, and started screaming. Hehe. No. I opened my website code in PhpStorm. I changed a couple of settings, telling it that I was now using PHP 8 and ES6. Its previous settings were for php7.4 and ES4.

I then ran an inspection on the entire project which tells PhpStorm to run Linters on the HTML, Sass, Javascript, and PHP. Ouch. I had 20+ PHP code errors that broke the website caused by backward-incompatible changes in PHP 8. Yes, I should have been listening to the warnings regarding depreciated code.

I also had 50 or so warnings that don’t stop the website from working but could very well be bugs or potential bugs due to depreciated features that could very well disappear in newer versions of PHP. I also had hundreds of soft warnings that could be as simple as an unused but declared variable or a typo. Now that is a lot of work if I had to make each and every one of those changes by hand. However, PhpStorm offers to fix a majority of them for me automagically.

I don’t let the IDE just take control, making all the changes in all the files all at once. I have had bad experiences with that. For certain warnings, I did let it change all the files that had potential problems. For example, for one soft warning, I let it go to town changing 40+ files in less than a minute. It would have taken me hours to fix them by hand.

But, for most errors I have to look at each file individually; that is just who I am. I run the inspection again on each file and then, if I am sure it is ok, I let PhpStorm make the changes it recommends on that file. In only a few instances did I have to actually do some typing. Even with my hands-on approach, what could have taken weeks to fix, took only hours. Well, not quite.

PhpStorm isn’t Just for PHP

It sounds as if PhpStorm is just a giant linter, but really, that is just one of the many features. It just happened to be the thing that solved my problem. First and foremost, PhpStorm is a smart PHP/HTML/CSS and Javascript code editor. PhpStorm has support for remote deployment, database testing tools, Docker, Composer, and more. It even has a Live Edit feature that allows you to see in a web browser instantly any changes you make in your code.

So while it is named PhpStorm, it is really a complete storm of web development tools. HTML5, CSS/Sass/Less, ECMAscript/CoffeeScript and more. It supports JSDoc and Javascript debugging and unit testing. The database support includes the ability to connect to your database server for testing SQL, in many different flavors.

It supports many popular Version Control Systems, including git and GitHub. It supports many of the common frameworks for PHP, Javascript, and CSS. The code editor makes writing new code or changing old a snap. It does amazing things to help you write/test/debug the best PHP code you can write including good documentation via support for phpDoc doc blocks. It even has third-party plugin support that extends its capabilities.

PhpStorm Found Logic Errors

It is a good thing PhpStorm is more than just a linter. Remember that one instance where I let PhpStorm make a change to multiple files at one time? There was one little suggestion for a change regarding type hinting that was new to PHP 8 that I said, yeah, that is a good idea and just let PhpStorm storm through the changes on my whole project. “It shouldn’t break things.”

It was only after making sure that the inspector showed no errors that I actually start testing. That sounded right but it was a big mistake. I should have fixed the major errors first, done some testing, then gone back to the soft errors. Although the linters did not show any errors, that one type hinting change broke gobs of my code due to old kruft that doesn’t present as errors but is due to programming logic mistakes.

I could have just used git to roll back all the changes and start over, (might have been the right thing), but I decided to make this a learning experience and a chance to remove some of the kruft on the way.

Debugging Tools

PhpStorm has really nice built-in debugging tools including the ability to trace through the code and see exactly where the problem exists. It uses a debugging tool built into PHP called xdebug. You have to enable it and configure it on your web server, not always easy but PhpStorm ‘s excellent documentation can help one get it all set up.

Once done, you can step line by line through the code, right there in PhpStorm, jumping from file to file until the problem presents itself so you can quickly fix the code issues right there in the file and get on with it. So from start to finish of the development process, PhpStorm can be your one ring to rule them all.

PhpStorm Licensing

PhpStorm is available for Macintosh, Windows, and Linux. PhpStorm is a subscription model program and for some, not cheap. It has both a monthly and an annual subscription plan. The annual plan reduces the price the longer you maintain it. Right now for an individual, it is $89 for the first year. The second year is less and from the third year onwards it is even less, at this time $53/year which is a significant saving over the monthly subscription price.

They do have special offers, including it being free for verified university students and teachers. The annual subscription plans or at least 12 months of the monthly plan even include a perpetual fallback license that allows you to use a specific version of software without an active subscription for it.

The time it saves me often results in huge savings for both me and my clients. Jet Brains is constantly updating PhpStorm, coming out with new versions with new capabilities at a fast pace. The subscription price is well worth it. Even mostly retired me finds this one indispensable tool that I just can’t give up.

1 thought on “PhpStorm – An IDE Not Just for PHP – by William Reveal

  1. Elastic man - June 12, 2022

    “ebugging Tools” This is what I was looking for

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top