Getting Started

This tutorial assumes you have the following applications installed:

  • Visual Studio 2012

PHPTools for Visual Studio

DEVSENSE has developed a fascinating plugin for Visual Studio – PHPTools. This plugin supplies IntelliSense and code completion, function definitions and documentation, as well as the ability to debug PHP – all inside of Visual Studio 2012.

Download the PHP Tools trial for free for 30 days to get started. Once it is installed, restart your Visual Studio project.

Creating and Debugging a Solution in Visual Studio

To create a project, go to FILE -> New Project… and select “PHP Web Project” under Templates -> PHP (image: Let’s start with some basic PHP for us to debug:


< ?php

class Car {
    private $make;
    private $model;
    private $year;

    public function __construct($make, $model, $year) {
        $this->make = $make;
        $this->model = $model;
        $this->year = $year;
    public function render() {
        echo $this->year . " " . $this->make . " " . $this->model;

$mustang = new Car("Ford", "Mustang", 2002);


Now, let’s set a breakpoint on line 19 and press the “Start” button in Visual Studio to debug and let’s see what happens.


Hitting “Start” will allow Visual Studio to hook into your local HTTP server (Apache) and XDEBUG (an extension installed by XAMPP) to allow you to debug (you will see “?XDEBUG_SESSION_START=1” in the URL).

So now they we’ve started debugging, we quickly hit the breakpoint we set. If you right-click $mustang and click “Add Watch”, you can see the value of $mustang. At line 19, it is has not yet been set.

AddToWatch PHP

Press F10 to go to the next line – you will see in your Watches window that we now have a Car object.


While on line 20, press F11 to step into the Car->render() function. We can see that the code ready to echo out the variables. Press “Continue” to finish the script and the result will display in your browser.


You have now successfully debugged a PHP script in your browser! This approach can be taken with many applications – including WordPress

See our CMS Web Development Page for more ways we can help you!