VS Code + Laravel Homestead + XDebugでデバック環境構築
VS Code + Laravel Homestead + XDebugでデバック環境構築を構築しようとしましたが、ハマったしまったのでメモ。
私の環境
- Windows 10 Pro
- Vagrant 2.1.2
- Homestead v7.2.1
- PHP 7.2.5 (Homesteadデフォルトのバージョン)
- XDebug v2.6.0 (Homesteadデフォルトのバージョン)
基本的には下記のページを参考にしました。
Directions for debugging using Xdebug, VSCode, and Homestead. · GitHub
Homestead Laravel Xdebug · Issue #220 · felixfbecker/vscode-php-debug · GitHub
/etc/php/7.2/fpm/conf.d/20-xdebug.ini の設定は
zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_host=10.0.2.2
xdebug.remote_autostart = 1
のみです。
xdebug.remote_connect_back = 1
が書いてあったら消しておく。
(私の保存場所はD:\workspace\laravel_work\.vscode\launch.jsonです。)
Homestead.yamlの設定を一部抜粋
folders:
- map: D:\workspace\laravel_work
to: /home/vagrant/code
私の環境では${workspaceRoot}はD:/workspace/laravel_workになるはずですが
pathMappingsの設定を上記コメントアウトの設定ではなぜか動かず。
${workspaceRoot}にしたところデバッカが動いた。