Setup Visual Studio Code + Laradock + xDebug

Viusal Studio Code

Laradock

xDebug

Edit the .env file inside the Laradock folder

  • nano .env
  • Find WORKSPACE_INSTALL_XDEBUG and replace it’s value by true
  • Find PHP_FPM_INSTALL_XDEBUG and replace it’s value by true

Edit the xDebug configuration files

  • nano workspace/xdebug.ini
  • nano php-fpm/xdebug.ini
  • Replace the contents of both files with:
xdebug.remote_host=host.docker.internal
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.idekey=VSCODE
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.cli_color=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir="~/xdebug/vscode/tmp/profiling"
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1

Rebuild the workspace and php-fpm containers and restart them

  • docker-compose build workspace php-fpm
  • docker-compose up -d workspace php-fpm
  • docker-compose restart workspace php-fpm

Activate xDebug in Visual Studio Code

  • In the Visual Studio Code menu, click Run and then Add Configuration
  • Add the configuration below:
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"pathMappings": {
"/var/www": "${workspaceRoot}",
},
"ignore": [
"**/vendor/**/*.php"
]
}

Start/Stop xDebug

--

--

--

Full Stack Web Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

I guess I became a developer in Toronto

Road to your future.

Connecting Amplify AppSync to an imported DynamoDB Table

Flutter Internationalize (Multi-language feature on flutter)

Top 10 software blogs and websites in 2020

Image Source: theverge

Coding Bootcamp vs. Online Video Courses (or Both) —Part 2

Li3 — most RAD development framework for PHP

SSH into EC2 instance on different Operating System

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Luis Coutinho

Luis Coutinho

Full Stack Web Developer

More from Medium

How I set up a new Mac in minutes with a simple Homebrew script

How to decorate an existing Sylius repository for plug-in purposes — BitBag

Create Unit tests for WordPress Plugin

How to manage your Materialize migrations with Laravel Zero?