Configurar Visual Studio Code + Laradock + xDebug

Viusal Studio Code

Laradock

xDebug

Editar o ficheiro .env na pasta do Laradock

  • nano .env
  • Procurar WORKSPACE_INSTALL_XDEBUG e substituir o valor por true
  • Procurar PHP_FPM_INSTALL_XDEBUG e substituir o valor por true

Editar os ficheiros de configuração do xDebug

  • nano workspace/xdebug.ini
  • nano php-fpm/xdebug.ini
  • Substituir o conteúdo de ambos os ficheiros por:
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 e reiniciar os containers workspace e php-fpm

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

Activar o xDebug no Visual Studio Code

  • No menu do Visual Studio Code, clicar Run e de seguida Add Configuration
  • Adicionar a configuração seguinte:
{
"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.

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 to decorate an existing Sylius repository for plug-in purposes — BitBag

Decoupling frontend and backend development — The easy way!

Convert a local development folder into a Git repository

15 useful Git commands every developer needs to know