So I've been using XAAMP to run PHP on my laptop and it works as it should. But it requires me to use a URL and then find the projects within the htdocs folder. I was wondering if there was something like Live Server that I could activate from Visual Studio and have it appear in the Web Browser.
I've done google searches on this already and it led me to download php extensions like php server and the php debugger extension.
However, I am a bit confused by these and what they do and I'm not sure if this is supposed to perform in a similar way that live server performs.
I've ran into issues though in getting VS Code to use the correct environmental variable. It keeps throwing an error that says the binaries couldn't be found or executed even though I have the path set in the json file to the folder holding the PHP related code.
I'm a bit confused and I'm also curious about whether or not what I'm trying to do is achievable or not.
Videos
How do I debug PHP in VS Code?
What’s the best way to format PHP code?
How do I enable error reporting in VS Code?
Debugging PHP with VSCode using the vscode-php-debug extension
VSCode can now support debugging PHP projects through the marketplace extension vscode-php-debug.
This extension uses XDebug in the background, and allows you to use breakpoints, watches, stack traces and the like:

Installation is straightforward from within VSCode: Summon the command line with F1 and then type ext install php-debug
As far as I read about it today, you can't debug anything else than node.js, JavaScript and TypeScript at the moment, but they said they want to add new languages which you can debug. The editor is still in development. Nevertheless, I don't think there will be a php debugger in the future since php is serverside, so you can't debug it on your client alone.
If you want to debug php, I can recommend xDebug.
Updated:
Now, it is possible to debug with VS code. You need to install XDebug and php-debug extension for VScode.
Hi there - I need help setting up PHP on VScode - I'm currently just trying to learn how to set up an account creation form on my website and am trying to link my html form to the php file to save the data but it's not working (I'm assuming it's because I don't have php setup). Can anyone give me a clear setup of instructions to run PHP on Vscode? I'm on Mac if that helps - I'd really appreciate it. Thank you!
Looks like you in fact don't want to run PHP from Visual Code, but instead you're trying to get PHP to work at all.
- add in external php file which I created now
You're using short tags and that's ok, if your configuration allows it, however I would recommend using explicit PHP tags: <?php echo "My First PHP site in VSCode."; ?>
In my index.html file I referenced my php file like:
There's the problem. You're placing PHP code in a HTML file. PHP code in HTML files won't be (at least by default) executed. Change the filename from index.html to index.php.
That should do it.
For running simple php website below are the two short steps
1. In VS code install PHP debug extension
2. From terminal run the command
php -S localhost:8080
By default VS is not made to run PHP, but you can do it with extensions:
You can install an add-on with the extension manager, PHP Tools for Visual Studio.
If you want to install it inside VS, go to Tools > Extension Manager > Online Gallery > Search for PHP where you will find PHP Tools (the link above) for Visual Studio. Also you have VS.Php for Visual Studio. Both are not free.
You have also a cool PHP compiler called Phalanger:

If I'm not mistaken, the code you wrote above is JavaScript (jQuery) and not PHP.
If you want cool standalone IDE's for PHP: (Free)
- Netbeans: https://netbeans.org/downloads/start.html?platform=windows&lang=en&option=php
- Eclipse: http://www.eclipse.org/downloads/packages/eclipse-php-developers/heliosr
Maybe we should help you with a big misunderstanding on your side first: PHP is (like ASP.NET or whatever you used to far) a server side language while javascript is client side.
This means that PHP will run on your webserver and create a HTML page dynamically which is then sent to the browser. Javascript in turn is embedded (either directly or as a referenced file) into this HTML page and runs in the browser.
Maybe you can now understand why your approach so far could never work out.