PHP Development with Visual Studio Code

August 8, 2017 | No Comments | Programming | PHP Visual Studio Code

Recently I tried Visual Studio Code – incredible tool which helps me a lot in my daily routine. Absolutely cross platform and free. Let’s try to install it on Ubuntu 16.04 and discover some features.

Note! I don’t compare VS Code with my IDE. They have different purposes and I use them in different cases.


For Ubuntu 16.04  we should download deb package from this link

Then install downloaded deb package via command where xxx version of downloaded package

sudo dpkg -i code_xxxx_amd64.deb

So let’s create new project and simple php file from terminal:

mkdir php-sample && cd php-sample && touch index.php &&  code .

Let’s write simple hello world and save. You will see almost the same window.

If you’re fan of Vim so you can install extension called Vim. Really useful thing for me. Just find it in extension tab and install. You will also learn how easy is installing extensions in VS Code compared to other text editors.

Working with Git

So let’s init our git repo

git init .

In editor you can check tab to Version Control, stage changes and commit them. Branch is displayed in status bar and can be changed. Version Control tab displays changed files. Changed lines are shown directly in file view.

There are a lot of options it dropdown menu (… at top) such as Pull / Push / Checkout. Really useful when you don’t want to use command line for routine work.

Run/Debug PHP Scripts

Let’s assume you want to write and run simple PHP CLI script. So we can run it straight from VS Code.

In Ubuntu 16.04 with installed PHP7 and Xdebug extension it’s enough to install PHP Debug extension. Then create configuration in launch.json, go to debug tab and press run. You will see output of your script in console.

    "version": "0.2.0",
    "configurations": [
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000

Xdebug configuration /etc/php/7.0/cli/conf.d/20-xdebug.ini
xdebug.remote_autostart = 1

Point breakpoint on needed line and press run again. You should see debug information in left side menu


I would recommend to use Visual Studio Code. It just works and don’t need a lot of configuration like Vim. Let’s list all advantages of VS Code:

  • Free
  • Cross Platform
  • Open Source
  • Built In Git plugin
  • Powerful Extension System
  • Simple configuration using JSON

Of course list of advantages and disadvantages can be personal for any of us, but this is first editor which worked for me perfectly.

About the Author / Artem Zhuravlev

Artem Zhuravlev. Web developer. Blog writer.

Need help with your website ? Contact with me by email for services of experienced web developer.

Follow @infernosquad