How can I debug PHP Laravel on Visual Studio Code without use XAMPP or WAMP server

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Debugging PHP Laravel in VS Code Without XAMPP/WAMP: Mastering Xdebug

As a senior developer, I understand the frustration of setting up local development environments. Installing and configuring tools like XAMPP or WAMP is essential for general web development, but sometimes you need a lighter, more specific approach—especially when working with modern frameworks like Laravel. The core question is: How can I step through my code in Visual Studio Code (VS Code) while debugging PHP Laravel without relying on a heavy external server installation?

The answer lies squarely in mastering the power of Xdebug combined with using Laravel’s native development server. This method allows you to debug your application directly within VS Code by leveraging an ephemeral, local environment provided by the framework itself.

The Foundation: Understanding Xdebug for Remote Debugging

Xdebug is the indispensable tool for deep debugging in PHP. It hooks into the execution flow of the Zend Engine and allows external tools (like IDEs) to pause execution at specific points (breakpoints) and inspect variables. To achieve server-less debugging, we need Xdebug configured not just to listen for connections, but to communicate correctly with a running process.

For this setup to work, you must ensure that your PHP installation has Xdebug enabled and configured to listen for remote debugging requests. This usually involves modifying the php.ini file, ensuring directives like xdebug.mode are set appropriately, and setting up host/port communication.

The Solution: Leveraging php artisan serve

The key to avoiding external server installations (like XAMPP or WAMP) is utilizing Laravel’s built-in development server via the command:

php artisan serve

When you execute this command, Laravel spins up a lightweight, temporary HTTP server on your local machine, typically running on http://127.0.0.1:8000. This server acts as the necessary entry point for your application, providing the context that Xdebug needs to connect and attach its debugger session.

Here is the step-by-step process to integrate this into VS Code:

Step 1: Configure Your Debugging Listener (Xdebug)

Ensure your Xdebug configuration points to a port that can be accessed by both your running PHP process and VS Code. For remote debugging, you typically set up Xdebug to listen on a specific host and port (e.g., host=127.0.0.1, port=9003).

Step 2: Configure VS Code Launch File (launch.json)

VS Code uses the launch.json file to understand how to start and attach debug sessions. You will configure a "PHP Debug" configuration that tells VS Code where to connect when it detects an active request from your Laravel application.

A typical setup involves configuring VS Code to listen for Xdebug connections, which are initiated by the server you just started:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003 // Ensure this matches your Xdebug port configuration
        }
    ]
}

Step 3: Debugging Workflow

  1. Start the Server: Open your terminal in your Laravel project root and run php artisan serve.
  2. Start Listening in VS Code: Go to the Run and Debug view in VS Code, select the "Listen for Xdebug" configuration, and click the green play button. VS Code is now waiting for an incoming debugging connection.
  3. Set Breakpoints: Open your controller or model file where you need to inspect variables (e.g., inside a method that handles a request). Set a breakpoint on the line of code you want to examine.
  4. Trigger the Request: Navigate to your application in a web browser (or use a tool like Postman) and trigger the specific action that will lead execution to your breakpoint.
  5. Execution Pauses: When the request hits your breakpoint, Xdebug intercepts the execution flow, pauses the script, and sends the context back to VS Code. You can now inspect local variables, step over lines, and fully trace the logic of your Laravel application.

Conclusion

Debugging a Laravel application in VS Code without installing external server stacks is completely achievable by correctly configuring Xdebug to interface with Laravel’s lightweight php artisan serve. This approach maximizes your development efficiency by keeping your environment minimal while providing the necessary deep-level introspection required for complex framework debugging. By mastering this integration, you gain the flexibility necessary to iterate quickly on your code, ensuring that the robust architecture of Laravel is debugged effectively from the start.