How do I configure vscode live server to process php files properly (I'm using Win10 and Chrome)?

How do I configure vscode live server to process php files properly (I'm using Win10 and Chrome)?

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

The Core Limitation of Live Server and PHP

Live Server is a fantastic extension for VS Code, but it operates under a specific architectural constraint that often trips up developers working with backend logic: it does not execute server-side languages like PHP, Python, or Ruby. When you open a file containing <?php echo 'Hello'; ?>, Live Server serves the raw source code to your browser because it relies on a static file watcher rather than an application server.

This behavior is by design. Live Server uses Node.js and Chokidar to watch for file changes and serve them directly via a simple Express-based HTTP server. It doesn't spawn a PHP process, nor does it have access to the php.exe executable you installed on your Windows 10 system. Consequently, when you hit refresh in Chrome after saving a .php file, you see the code instead of the rendered output.

To get Live Server to handle PHP files properly, you must switch from a static file server to a dynamic application server. The "secret sauce" isn't a hidden configuration flag within VS Code; it is changing how your development environment serves content.

Using Xdebug for Debugging vs. Running the Server

There is a common misconception that enabling Xdebug or installing browser extensions like live-server-web-extensions will make Live Server execute PHP code. While these tools are useful, they serve different purposes.

Xdebug is a debugging extension that allows you to set breakpoints and inspect variables, but it requires a PHP server (like Apache/Nginx or CLI) to actually run the code first. The browser extension mentioned in your scenario helps with page reloads after saving a file, but it cannot bridge the gap between raw source code and executed output on its own.

If you are relying solely on php.exe from the command line, you are likely invoking the CLI version of PHP to serve files, which is not how web servers function. Web servers require a specific configuration for document roots, error pages, and module loading that the CLI does not provide by default.

The Solution: Switching to a Dynamic Server Stack

To resolve this issue while keeping VS Code as your editor, you need to introduce a PHP application server into the mix. The most common approaches involve using Apache with mod_php or switching to a lightweight standalone PHP server like php-sapi-fpm or simply running a built-in PHP development server if available in your version.

However, the cleanest modern approach for local development on Windows 10 is often to use Apache configured with mod_php, or to utilize Vagrant/Docker to spin up a LAMP/LEMP stack. If you want to stick purely to PHP without setting up a full web server environment, you can try the php -S flag, but note that this is primarily for CLI scripts and may not handle require_once or complex autoloading setups correctly in all cases.

A more robust solution often involves using XAMPP or WAMP. These packages pre-configure Apache, MySQL, and PHP on Windows. Once installed, you can point VS Code to your project folder and run the local server using the command:

C:\xampp\apache\bin\httpd.exe -k start

Or, if you prefer a Node.js-based approach that mimics the Live Server experience but handles PHP via a proxy (like php-simple or similar wrappers), you might consider tools like Laravel Valet for Laravel projects specifically.

Configuration Steps for Apache and mod_php

If you decide to go with Apache, the configuration involves a few specific steps:

  1. Install XAMPP: This bundles Apache, PHP, and MySQL.
  2. Configure Document Root: Ensure your httpd.conf points to the correct directory (e.g., htdocs).
  3. Enable mod_rewrite: Essential for routing requests.
  4. Load mod_php: Add LoadModule php_module "C:/xampp/php/libs/apache/libphp8.dll" to your Apache config.
  5. Set Default Index: Ensure DirectoryIndex index.php is set so that .php files are recognized as entry points.

Once this environment is running, you can start the server via XAMPP Control Panel or command line. Your browser will then execute the PHP code correctly because Apache handles the request lifecycle and invokes the PHP interpreter before sending the HTML response to Chrome.

Trade-offs and Best Practices

While getting Live Server to process PHP directly is technically impossible without a dynamic server, there are workflow patterns that mitigate this limitation. You can configure VS Code to open index.html as the entry point, which then includes your PHP logic via AJAX calls or form submissions to an API endpoint. Alternatively, many developers simply use Live Server for frontend assets and switch to their local Apache/IIS server for full-stack testing.

If you are building a Laravel application specifically, consider using the official Laravel Valet tool or the built-in development server (php artisan serve). These tools handle the routing and execution natively. For general PHP projects, sticking to a traditional LAMP stack via XAMPP remains the most reliable method on Windows 10 without complex Docker configurations.

Remember that Live Server is optimized for static content delivery. To get full power of your PHP code, you must pair it with an application server capable of interpreting and executing server-side logic before sending data to the browser.

Our network