The project I was working on was a PHP application using Laravel, created by VS Code. I'm used to working with Java and Swift, but it's a reminder that I've been so addicted to PHP debugging for the first time in a while.
Since XDebug is used for debugging PHP, I read XDebug commentary article and read it (it is a very easy-to-understand article).
Many articles explain it carefully, so I will wrap up the details.
php.ini
;...abridgement
[XDebug]
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
xdebug.default_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_handler=dbgp
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal
xdebug.remote_log=/tmp/xdebug.log
xdebug.idekey=VSCODE
Dockerfile
FROM php:7.4-apache
# XDebug
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
#...abridgement
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"pathMappings": {
"/var/www/html": "${workspaceFolder}/src"
},
"ignore": [
"**/vendor/**/*.php"
]
}
]
}
With this feeling, I finished PHP initialization, Docker initialization, and XCode debug settings.
__ This doesn't work at all. __
I messed with various parameters, but it didn't work at all and I gave up, but eventually I realized that it was a problem with the version of xdebug.
$ php -v | grep -i "xdebug"
with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans
From Xdebug 2.x to 3.x, the __ setting value has changed. __ https://xdebug.org/docs/upgrade_guide It is described in detail and clearly in this document.
For example, xdebug.remote_log
has been renamed to xdebug.log
. No wonder, the log doesn't come out at all.
If you look at the detailed meaning there, the above php.ini
is now correct.
php.ini
;...abridgement
[XDebug]
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
xdebug.mode=debug
xdebug.client_port=9000
xdebug.start_with_request=yes
xdebug.discover_client_host=0
xdebug.client_host=host.docker.internal
xdebug.log=/tmp/xdebug.log
That's all from the field.
Recommended Posts