Visual Studio Code for PHP Developers

Out of the blue, Microsoft jumps into the editor wars with an incredible offering that gives Sublime Text an overwhelming run for its money. In fact, it just might surpass it! So come along, as I demonstrate the ins, the outs, the tips, the techniques. Say hello to your new best friend: Visual Studio Code.

Visual Studio Code for PHP Developers

Out of the blue, Microsoft jumps into the editor wars with an incredible offering that gives Sublime Text an overwhelming run for its money. In fact, it just might surpass it! So come along, as I demonstrate the ins, the outs, the tips, the techniques. Say hello to your new best friend: Visual Studio Code.

Let's next review the process of traversing your file system. Or, in other words, what is the fastest way to open a file, or a class, or a PHP method. It's vital that we streamline this workflow as best as we can.

The programming world splits into two groups: those who research Vim keybindings for each new editor they try, and those who are still figuring out how to exit Vim. If you're among the former, let's get these keybindings working.

Please don't manually type out your various class and method structures. These are perfect use-cases for custom snippets. Let's create a few together, while reviewing some key variable names to make them more dynamic.

If you're accustomed to opening a separate Terminal or iTerm window each time you need to trigger a console command, if you wish, you may now accomplish this directly from Visual Studio Code, via its terminal panel. Ctrl-` is your friend.

Ideally, each time I save a PHP file, it should apply PSR-2 formatting, as well any number of automatic code fixes that I desire. Let's learn how to accomplish that very thing in this episode. You'll love it!

We're getting nitpicky at this point, but that's okay. Having to reach for the mouse to right-click on a symbol to perform any kind of contextual action is a bit annoying. Let's instead assign a custom keyboard shortcut so that my hands can remain on the keyboard permanently.

It's always a little tricky to setup a good PHP debugging workflow in your editor. Luckily, Jose Soto has documented the setup process for us. Yay! Now, we can follow a few quick steps to arrange for powerful PHP debugging in Visual Studio Code.

The useful "Import Cost" extension allows us to automatically visualize the size of each JavaScript dependency we import. It does this by appending a small, non-intrusive label next to each import. Are you importing a massive dependency that you didn't know about? Well, if you are, this extension will make it crystal clear.

Let's supercharge our JavaScript (including Vue templates) error and style guide detection with ESLint. Once installed, you'll stop and wonder how you were able to code effectively before this wonderful addition to your tool belt.

What if we could add a single commented line to the top of any vanilla JavaScript file, and instantly activate advanced TypeScript type checking and error reporting? How cool would that be? Well - as it turns out, we can!