In previous posts, I’ve talked a bit about why using a proper debugger versus some of PHP’s built-in statements are important. In the last post, even, I walk through how to set up Xdebug with Visual Studio Code (and MAMP Pro, if you’re using).
But if you’ve never used a tool like this before, you’ve never seen how it works, or you’ve never seen why it’s so powerful, I want to cover that a bit in this post.
So I’m going to be walking through a bit of doing this within the context of a few definitions and screenshots as well as a short screencast at the end so I can show the Visual Studio Code debugger working in action.
Using Xdebug and Visual Studio Code is something that’s pretty easy to setup, but given that I’m still using Visual Studio Code should tell you something about how much I’m a fan of the IDE.
But here’s the thing:
If you’re a WordPress developer, debugging is something that you really need to learn. That is, don’t use
var_dump if you can help it. Use a legitimate debugger. It will help you think as the interpreter thinks and it will help you learn a bit more about Core.
Now that I’m off my soapbox, getting the necessary tools installed is easy. The article assumes you’re using MAMP Pro (since that’s what I use), but if you have access to php.ini then you’re going to be able to follow along.
If you’ve read any of my previous posts, you know that I think code sniffing (as funny as that sounds) is something that I believe to be a staple of any WordPress development environment. And this is how you can setup PHP CodeSniffer in Visual Studio Code.
But first, a word about Code.
Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring.
I’ve been using Code as my primary IDE for years at this point and have been extremely happy with it. I’m not going to belabor the points as to why. I’ve written about them in other posts.
But here’s how to set up PHP CodeSniffer in Visual Studio Code. Continue reading
VS Code is a new editor from Microsoft (I guess some may insert an obligatory flaming remark here, but I think they’ve done some pretty good stuff as of late) that I’ve only been following off and on since it was first announced.
Before working for myself, I was focused on .NET development and to this day, I’ve yet to find an IDE that I like as much as that.
But then, late last week, I saw this tweet:
Followed by this:
And then this resulted in a good, albeit short conversation.
I’ve never been a fan of switching IDEs in the middle of client projects (for some reasons), so I didn’t plan on giving this particular IDE a try for the foreseeable future.
But given that I’ve got a set of unfinished projects lying around and given that I had some time to myself this weekend, I opted to see how well VS Code worked with a couple of WordPress-based projects.