PHP Classes

Using Microsoft Visual Studio as PHP IDE with the PHP Tools extension: Part 1 PHP Editing Support

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog Using Microsoft Visua...   Post a comment Post a comment   See comments See comments (5)   Trackbacks (0)  


Viewers: 8,141

Last month viewers: 180

Categories: PHP Tutorials, Sponsored

Microsoft Visual Studio is a very popular IDE among developers using Windows but it does not come with built-in support to PHP. On the other hand, 75% of the PHP developers use Windows when they are developing their PHP projects.

Fortunately for Visual Studio fans there is an extension called PHP Tools that adds PHP support to that IDE and works with the Microsoft Visual Studio.

Read this first part of the article to learn how to use the PHP Tools extension so you can setup and edit PHP code projects from Visual Studio.

Loaded Article

PHP Support for Visual Studio 2017 and Visual Studio 2015

Why use an IDE?

Tools of the Trade

Installation Could Not Be Easier

Setup for Local Development


PHP Support for Visual Studio 2017 and Visual Studio 2015

Visual Studio is a popular Integrated Development Environment (IDE) provided by Microsoft to manage projects for Windows and the Web. It has built in support for Microsoft products like Visual C++, Visual C#, Visual Basic and Visual Web to name a few. It also supports product extensions so that you can work with additional languages in a familiar environment.

Devsense provides a complete package of PHP Tools that extends the Visual Studio IDE to support the PHP scripting language, currently up to PHP version 5.6 (soon PHP 7 too), HTML, CSS and Javascript.

It also makes use of a built in Web server so that you are not required to set up your own for local development and the xDebug debugger. Visual Studio 2017, 2015, 2013, 2012 and 2010 are all supported, the exception being the express edition which does not support extensions.

In this series I will be using Visual Studio 2015 Community Edition, which is available for free from Microsoft, and PHP Tools version 1.19 which is available for free for a full 30 day evaluation from Devsense.

In this first part of the series I will be looking at the features available, installation, and set up. In the second part I will explore using the IDE with practical examples. In the third part I will demonstrate using the debugging features.

Why use an IDE?

PHP, HTML, CSS and JavaScript can all be written using any simple text editor. This is how it was done long before any IDE's where available and how it is still being done by many freelance developers.

Eventually your projects will become more complex and with that complexity they become harder and harder to manage. An IDE will provide the tools to make you work easier and more productive.

Anyone who knows me, knows that I like to compare programming to the construction industry. Consider building a house. The only tools you really need are a hammer and hand saw. However given the choice I would much prefer to use measuring tapes, circular saws and nailers. These tools allow me to construct in a couple of days what would take months without them.

So, let us take a look at some of these tools available to us using the Visual Studio IDE and PHP Tools extension.

Tools of the trade

Coding is nothing more than providing a set of instructions in a supported language that can be interpreted. In our case, we are using the PHP scripting language that has its set of rules and particular syntax requirements.

code highlighting

Code Highlighting

Code highlighting is a feature provide by smart editors to colorize different parts of code so that we can easily, visually identify them.

code completion

Code Completion

Code completion is a feature which provides you with options to choose language constructs based on what you are typing. This gives you the ability to only type a few characters and let the editor complete the rest.

These suggestions also include functions, properties and methods from included files which is a real time saver by allowing you to stay in the file you are currently working on.

code folding

Code Folding

Code folding is a feature which allows you to shrink and expand code blocks, so that you can hide any code you are not currently working on. It is also a convenient way to provide detailed comments without them taking up a lot of your workspace while coding. Devsense refers to this feature as outlining.

smart indenting

Smart Indenting

Smart indenting is a feature to help keep your code readable by indenting code contained in blocks. If you have ever tried tracking down an extra closing bracket in code that is not indented, you will instantly understand the benefit of this.

Reference Highlighting

Reference highlighting is a feature that allows you to quickly identify and find code with the same reference. If you need to find all instances of a call to a particular method, this tool will automatically do the search for you.

task list

Task List

The task list is an easy way to use comments to indicate tasks that still need to be completed in your code. It will generate a list of all instances where the keyword TODO or PHP Doc @todo is found and present the comment, file and line number.

error highlighting

Error Highlighting

Error highlighting is a feature that will identify and describe syntax errors in your code, making short work of fixing those pesky typo's.


When you want to for instance rename variable, you just do it on some occurrence, then press Ctrl + . and you will see the possibility to rename all the occurrences.

Refactoring all variable occurences in PHP Visual Tools

Installation Could Not Be Easier

If you do not already have Visual Studio installed, the first step will be to download it from Microsoft and run the installer. Installation is very simple, the installer will automatically download, install and set up the components.

This process can take several minutes to complete. Once complete, run Visual Studio so that it can complete the tasks which run during the first initialization. Close Visual Studio so that you can install the PHP Tools extension.

Next you will need to download the latest stable version and run the PHP Tools file from Devsense. The installer will determine which versions of Visual Studio you have installed, select the IDE's you want to extend and click the Install button. Once the installation has completed, run Visual Studio and it will complete the integration.

It is really very simple and you will now have the option to create new packages using PHP.

Setup for Local Development

To develop PHP applications locally, you will need a Web server and xDebug. Once you have written some code, the first time you test it you will be given the option to set up the built in web server or to manually configure the IDE for one you already have installed.

For our purposes, we will use the built in Web server since all you need to do is select this option and launch it. The IDE will take care of downloading and configuring both PHP and xDebug in one simple step.


If you are already a user of Visual Studio, it is a no brainer to use the same IDE for your PHP projects. If you are looking for an IDE, one of the main advantages with this solution is that ability to have support for several languages in one place.

While Visual Studio 2105 Community Edition is absolutely free, the PHP Tools extension is licensed with a fee but you can download it for free from the  site to evaluate it at no cost.

The PHP Tools full version cost is comparable to other IDE's which support PHP, so you will need to decide if making a small investment is worth the gains in productivity that professional tools will provide.

Given that Microsoft Visual Studio by itself supports many other languages already, like for instance JavaScript, it may be a good option considering that benefit for Web developers.

In the next installment of this series we will get much more involved in creating a PHP project, adding multiple files and testing our code locally as we develop.

For now, if you liked this article, please share it with other developers interested in this tool. If you have a question, post a comment here.

You need to be a registered user or login to post a comment

Login Immediately with your account on:


3. Don't Tell My Boss! - Chris (2016-04-27 07:26)
Php nerds be very afraid... ;D... - 1 reply
Read the whole comment and replies

1. PHP Tools by Devsense are sponsor of the PHP Innovation Award - Donato Greco (2016-04-26 17:54)
You should evidence Devsense is Sponsor of the PHP Innov Award... - 1 reply
Read the whole comment and replies

2. LIKE - Ruslan Aliyev (2016-04-26 17:25)
thanks for good topic!... - 0 replies
Read the whole comment and replies

  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog Using Microsoft Visua...   Post a comment Post a comment   See comments See comments (5)   Trackbacks (0)