VS Code for PHP Development
VS Code for PHP Development
When we think about the VS Code IDE, 'PHP development' probably isn't the first thing that springs to mind. But maybe it should. Read on for some reasons why.
Join the DZone community and get the full member experience.Join For Free
Although most of my work time is spent on ASP.NET and SharePoint development, I also have some PHP projects. I have my own favorite thin tooling for PHP but I decided to give Visual Studio Code (VS Code) a try with one of the projects. This blog post describes what I have in my dev box and what my first impressions are of using VS Code for PHP development.
Why VS Code?
VS Code is not an IDE like Visual Studio. It is also not a simple code editor with a few commands and syntax highlighting. It sits somewhere in the middle, making it a simple yet powerful tool thanks to the fact that it supports extensions. The main reasons why I considered trying out VS Code for PHP development are:
- It’s free and cross-platform (Linux and Apple are also supported).
- It’s is way smaller than Eclipse, NetBeans, and other big IDEs.
- It’s is more advanced than Notepad++ and other simple code editors.
- It’s is well supported by Microsoft and the developer community.
- There are many extensions available for different languages and file formats.
Those who want to get the newest features first and play with raw bits and bytes of VS Code can download the VS Code Insiders version. It is installed side-by-side with stable versions and they don’t conflict with each other.
PHP Tooling on VS Code
I use IIS to build PHP sites on my dev box so I don’t have to keep editors and other development tools running when showing something to a customer from my machine. I have PHP 5 and PHP 7 installed and configured for IIS, meaning that I don’t need to run PHP directly from VS Code. The following screenshot shows the VS Code editor and file explorer. Notice how SQL is also highlighted in the string.
I installed PHP IntelliSense extension by Felix Backer to have advanced syntax highlighting for PHP. Besides syntax highlighting, this extension has the following useful features:
- Code completion
- Signature help
- Workspace symbol search
- Find all references
- Go to definition
I don’t have big or complex PHP developments going on and PHP IntelliSense plugin is currently enough for me.
Debugging PHP Code
Sooner or later my demands will grow and it’s possible I'll want to run PHP code on a debugger so I can see what’s going on exactly. For this, I found PHP Debug Adapter by Felix Backer (again!). Take a look at this short GIF-video from the plugin's GitHub repository to get a better understanding of what his debugger can do.
Looks impressive considering that something like this is running on some thin code editor.
My Experiences Thus Far
I have used VS Code for PHP development for a few weeks and here are my first impressions:
- VS Code is stable and fast.
- PHP development is well supported by different plugins.
- Code navigation is almost as convenient as it is in Visual Studio.
- VS Code has a clean and simple UI with almost no clutter.
- Git tools work well but a more informative UI would be better (not a big issue).
Those who doubt if VS Code is really good for PHP development should definitely try it out and it doesn’t matter what platform you are using. I’m happy with VS Code and PHP!
Published at DZone with permission of Gunnar Peipman , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.