
I'm keeping it here in case it is useful. In this tutorial, we walk you through setting up Visual Studio Code and give an overview of the basic features. There is no reason to use it over the build task method described above.

I originally thought that it works without PHP Debug but it looks like PHP Debug actually exposes the php type in the launch configuration. Note: This section was in my original answer.
HOW TO USE VISUAL STUDIO CODE FOR PHP UPDATE
Note that if you already have a webserver running, you can remove the Start Server task and update the localhost:8080 part to point to whatever URL you are using. If you want to run your code on a webserver which serves a response to a web browser, open the command palette and select "Tasks: Run Task" followed by "Start Server" to run PHP's built-in server, then "Run In Browser" to run the currently open file from your browser. If you want to run your php file in the terminal, open the command palette and select "Tasks: Run Task" followed by "Run In Terminal". The following steps should be taken outside of Visual Studio Code: Navigate to the index.html. This creates user-level tasks which can be used any time and in any workspace. At this point, your file is ready to be viewed in a web browser. You might also consider using the same server that your production environment would use to minimise differences between your development environment and other environments your code will run in.

PHP has a built-in development server which is quick to get up and running.

Now copy my configuration below into your tasks.json file. You need to use a web server which supports PHP instead. PHP in Visual Studio 2019 Getting StartedPHP code is usually processed on a web server by a PHP interpreter implemented as a module, a daemon or as a Commo. Using Build Tasks (No extensions required)įirst open the command palette ( Ctrl+ Shift+ P in Windows, ⌘+ Shift+ P in Mac), and select "Tasks:Open User Tasks".
HOW TO USE VISUAL STUDIO CODE FOR PHP INSTALL
If you don't want to install xDebug or other extensions and just want to run a PHP file without debugging, you can accomplish this using build tasks. When you install PHP on your computer you can then use the PHP Server extension with VS Code to launch a site.
