My student license for PHPStorm finally expired. You would think that as a tool I use daily for my day-job and for my hobbies would be worth the cost, but after looking at the pricing for a normal license, there simply was no justification for me spending that ridiculously-huge amount of money to develop things that were either open source hobbies or things I can write with other tools.
Enter Visual Studio Code.
Out of the box, Visual Studio Code looks decent, or at least way better than the Atom UI on Windows (Have you seen that ugly menu bar on Atom? Jeez.)
Granted, it took a bit of getting used to, but it's close enough to replicate my PHPStorm workflow. The Visual Studio Code Marketplace is awesome, having a lot of useful stuff that emulates some PHPStorm functionality.
These are the plugins I use:
Auto Close Tag by Jun Han
Basically, this extension auto-closes your tags after typing the opening tag (as you can possibly comprehend from the sample above). This also works on other languages like PHP and a smothering of others.
Install and reload Visual Studio Code to activate this extension.
PHP DocBlocker by Neil Brayfield
This automatically creates a PHPDoc block once you enter a multi-line comment above your function. I really liked this feature in PHPStorm, since I always like to document my code. This was actually the only feature I need that convinced me to switch over.
Just like with Auto Close Tag, just install the extension and reload Visual Studio Code.
PHP Intellisense - Crane by Hvy Industries
This is the best IntelliSense extension for PHP, way better than the IntelliSense extension recommended by Visual Studio Code for PHP itself.
The best part is that this indexes your code and suggests the correct class to call, a functionality I've only seen in PHPStorm.
Granted, I would've preferred it to put a
use statement at the top instead of including the entire line. It was open source, so I forked the repository and I'm trying to 'fix' it to act like that instead. If I make it, I'll release it. If I can't do it, well at least I tried. Doing it manually in the meantime isn't a nuisance.
Note: After installing, disable the built-in PHP IntelliSense in VS Code so you don't get duplicates. You can do that by going to File > Preferences > Settings > Extensions > PHP and uncheck PHP Suggest: Basic.
vscode-php-cs-fixer by Frank Terragna
Have you ever looked at code and barfed? I reviewed a ton of code for a couple of students who were making their thesis, and a majority of their debugging problems come from poor indentation.
Every one doesn't follow the proper PSR standards. So if you (like me) strictly follow these, reading code made by other people is suicide. Enter CS Fixer.
This builds upon the Symfony CS Fixer library, and will automagically reconstruct your code upon saving so that it follows
basic human decency the PSRs.
I just noticed that the comment block in the GIF above was ungrammatical. It should be "watch it automagically TRANSFORM into a beautiful piece of poetry." Pardon my pedantry.
It's better if you learn the actual PSRs, but if you can't be bothered or you're reading something someone else
threw up wrote, this one's for you.
I normally don't use the other plugins since I don't have my native dev environment on my Windows machine (I'm running a virtualized instance like the cool kids). I only have a PHP 7.x binary so I can run composer from the Windows command line.
Git, the actual PHP used in my web server, Apache and the rest are inside the virtualized instance, so there's no need for Visual Studio Code to care about that. But if you're still on XAMPP, there are other plugins you might be interested in: