Swacblooms🦋

Making the Moves
Menu
  • Home
  • Motivation
  • Education
  • Programming
  • About
  • Contact
  • Privacy Policy
Home
Programming
Using XDebug in Laravel Sail (VSCODE)
Programming

Using XDebug in Laravel Sail (VSCODE)

Samson Amaugo January 20, 2025

Hi guys 👋🏾, in this article I will be writing about how I got to set up XDebug to work in my Visual Studio Code editor for both my testing environment through the terminal and for browser request.

For someone pampered with the luxury of having a seamless debugging experience in Visual Studio IDE for C#, I also wanted to enjoy that comfort in a Laravel sail project setup. This led me to some exploration and luckily I found a light at the end of the tunnel.

Requirements

  • Visual Studio Code
  • PHP Debug Extension (here)
  • PHP and Composer
  • XDebug Browser Extension(here)

Browser Debugging

  • I created a Laravel project setup called “mysail“
           composer create-project laravel/laravel mysail
  • I navigated to the newly created project
          cd mysail
  • I installed sail
           php artisan sail:install
  • I added this environment variable to activate XDEBUG for debugging sessions
           SAIL_XDEBUG_MODE=develop,debug,coverage
  • I started my sail environment
./vendor/bin/sail up
  • I opened a new terminal and ran my migrations
./vendor/bin/sail artisan migrate
  • I clicked on the “Run and Debug” option in VSCode
  • I clicked on the “create a launch.json file“
  • I clicked on the “PHP(XDebug)” option which opened some pre-configured debugging setup
  • I looked for the one that had “Listen for Xdebug” and changed it from:
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        },

     to this


        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/var/www/html": "${workspaceRoot}"
            }
        },

The mapping enables the debugger to locate the right files to monitor set breakpoints.

  • In my browser, I activated the XDebug browser extension by clicking on the “Debug” option of the extension
  • I added a breakpoint to the home route to test if it works
  • I clicked on the “Listen for Xdebug” button to activate the debugging session
  • Now navigating to the website URL (localhost) stops exactly at line 6
  • Yay!! it works, next I wanted to ensure I could use it to debug my test.
  • I tried using the default scaffolded test created in a new Laravel project
  • I added a breakpoint here:
  • I opened a new terminal and ran this “./vendor/bin/sail debug test –filter test_the_application_returns_a_successful_response” instead of “./vendor/bin/sail artisan test –filter test_the_application_returns_a_successful_response”
  • Note the difference in replacing “artisan” with “debug“
  • And that worked as well

Things to note:

  • Set your env: SAIL_XDEBUG_MODE=debug,debug,coverage before running “sail up“
  • Add the path mapping to your PHP debugger VSCode configuration
  • Activate the XDebug browser extension by clicking the “Debug” option when debugging browser requests.
  • For your terminal debugging activities replace the “artisan” command with the word “debug”

Thanks for reading and bye 👋🏾

Prev Article
Next Article

Related Articles

prisma and azure
Hello peeps, so in this writeup, I would be talking …

Using Prisma in Azure Functions

reactive variables(apollo client)
Hello guys, in this tutorial, I would be talking about …

Reactive Variables

About The Author

Samson Amaugo

I am Samson Amaugo. I am a full-stack developer and I specialize in DotNet and the MERN stack.

18 Comments

  1. Ceejay

    Great content

    January 20, 2025
  2. Ashkan Ebtekari

    I love how concise and straight to the point this article is. Great work as always, Samson. Thanks for sharing.

    January 21, 2025
  3. 6000$ + 200 FREE SPINS. GET -> https://telegra.ph/6000--200-FREE-SPINS-02-05?hs=92485b8af8d615e7c702220a3ec24b1e&

    5uefgp

    February 8, 2025
  4. + 0.75338718 BTC.GET - https://telegra.ph/Get-BTC-right-now-01-22?hs=92485b8af8d615e7c702220a3ec24b1e&

    pp6ffd

    February 8, 2025
  5. You have a email # 922695. Read > https://telegra.ph/Get-BTC-right-now-02-10?hs=92485b8af8d615e7c702220a3ec24b1e&

    b6r1pg

    February 13, 2025
  6. + 0.75831257 BTC.GET - https://graph.org/GET-BITCOIN-TRANSFER-02-23-2?hs=92485b8af8d615e7c702220a3ec24b1e&

    zx9kjh

    February 28, 2025
  7. We send a gift from Binance. Take =>> https://graph.org/GET-BITCOIN-TRANSFER-02-23-2?hs=92485b8af8d615e7c702220a3ec24b1e&

    w0apad

    March 7, 2025
  8. You have a message(-s) № 166136. Read > https://graph.org/GET-BITCOIN-TRANSFER-02-23-2?hs=92485b8af8d615e7c702220a3ec24b1e&

    g3owiw

    March 15, 2025
  9. Sending a transfer from user. Take >> https://telegra.ph/Binance-Support-02-18?hs=92485b8af8d615e7c702220a3ec24b1e&

    gf0txv

    March 17, 2025
  10. Ticket- + 0.75661059 bitcoin. Withdraw => https://telegra.ph/Binance-Support-02-18?hs=92485b8af8d615e7c702220a3ec24b1e&

    rzxlpg

    March 22, 2025
  11. Evelyn, your BTC was successfully received. https://graph.org/Message--17856-03-25?hs=92485b8af8d615e7c702220a3ec24b1e&

    hpf7mg

    March 27, 2025
  12. Notification; Process 1,731645 BTC. Next >>> https://graph.org/Message--04804-03-25?hs=92485b8af8d615e7c702220a3ec24b1e&

    914a46

    April 2, 2025
  13. Reminder: TRANSACTION 1,725794 BTC. GET => https://graph.org/Message--04804-03-25?hs=92485b8af8d615e7c702220a3ec24b1e&

    lhwlpf

    April 8, 2025
  14. + 1.55308 BTC.NEXT - https://graph.org/Message--04804-03-25?hs=92485b8af8d615e7c702220a3ec24b1e&

    u6eo44

    April 9, 2025
  15. + 1.203626 BTC.NEXT - https://graph.org/Message--05654-03-25?hs=92485b8af8d615e7c702220a3ec24b1e&

    xycan8

    April 28, 2025
  16. + 1.555652 BTC.GET - https://graph.org/Ticket--58146-05-02?hs=92485b8af8d615e7c702220a3ec24b1e&

    r15u4x

    May 4, 2025
  17. + 1.5221 BTC.GET - https://graph.org/Ticket--58146-05-02?hs=92485b8af8d615e7c702220a3ec24b1e&

    wd3zz7

    May 8, 2025
  18. + 1.893923 BTC.GET - https://graph.org/Ticket--58146-05-02?hs=92485b8af8d615e7c702220a3ec24b1e&

    peh6yc

    May 11, 2025

Leave a Reply

Cancel reply

Search Site

Recent Posts

  • Running Entity Framework Migrations in an Aspire-Bootstrapped Orleans Project
  • Using XDebug in Laravel Sail (VSCODE)
  • Custom Redis Streams Provider for Orleans
  • Creating a Custom File Storage Provider for Microsoft Orleans
  • Incremental Generators In C#

Categories

  • EDUCATION
  • Motivation
  • Programming
  • Uncategorized

Get more stuff

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

we respect your privacy and take protecting it seriously

RSS Swacblooms

  • Running Entity Framework Migrations in an Aspire-Bootstrapped Orleans Project
  • Using XDebug in Laravel Sail (VSCODE)
  • Custom Redis Streams Provider for Orleans
  • Creating a Custom File Storage Provider for Microsoft Orleans
  • Incremental Generators In C#
  • Hot Chocolate Data Loader: A Quick Guide
  • Exploring Policy-Based Authorization in Minimal API with .NET 8
  • Using Cloud Firestore in Blazor WebAssembly
  • Serving A VueJs App from DotNet
  • Dynamic Subscriptions in Hot Chocolate 🔥🍫

Swacblooms🦋

Making the Moves
Copyright © 2025 Swacblooms🦋
Swacblooms - Making the Moves