Debugging Laravel application on VSCode

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company
# Debugging Laravel Applications in VSCode: Achieving Full-Stack F5 Debugging Has anyone successfully configured Visual Studio Code to debug a full Laravel-based website using the familiar F5 key functionality? Many developers strive for this seamless experience—launching the web server and having the debugger pause execution exactly where needed, just like in full IDEs. While I have followed numerous tutorials, I’ve hit a wall: I can successfully set up debugging via XDebug (using "Listen for XDebug"), but standard VSCode launch configurations fail when trying to debug the application flow. This post addresses this exact pain point. We are dealing with the difference between debugging an isolated script and debugging a complex, framework-dependent application structure like Laravel. ## Understanding the Debugging Discrepancy You have correctly identified the core conflict: 1. **"Listen for XDebug":** This works because it tells VSCode to connect to an already running XDebug session (usually started by the web server), allowing you to step through code that is already executing in the context of the live request. 2. **"Launch currently open script":** This fails because it attempts to execute a single, isolated PHP file. When debugging a Laravel controller or model, these classes rely heavily on Composer's autoloader and framework bootstrapping. Launching just one file doesn't load the entire application context, resulting in errors like "cannot locate Controller class," as you observed. The issue is not with your setup (VSCode, XAMPP, XDebug are all correctly installed), but rather how VSCode’s debugger interprets a launch request in the context of a complex framework environment. We need to instruct the debugger to launch *within* the application's established context, not just an arbitrary file. ## The Solution: Launching the Application Context Correctly To achieve true F5-style debugging for Laravel applications, you must ensure that when VSCode launches the process, it is executing within the environment where Laravel has fully bootstrapped itself—meaning Composer autoloading and framework initialization are active. Since standard PHP debug extensions often struggle with launching entire web requests directly through `launch.json`, the most robust approach involves leveraging how your web server (like Apache or Nginx via XAMPP) handles execution, or using a slightly different launch strategy that respects the application's root. Here is the best practice configuration to bridge this gap: ### Recommended `launch.json` Configuration Instead of trying to launch arbitrary files, focus on configurations that allow VSCode to connect to an external process or use a mechanism that simulates the web request lifecycle. While the exact method can depend on your server setup (FPM vs. Apache module), the principle is to target the application entry point rather than a single view file. For many Laravel setups running via PHP