开发环境说明
IDE:Visual Studio Code
DNMP:https://github.com/yeszao/dnmp
项目:laravel
开启xdebug
修改dnmp/php/php72/Dockerfile,添加以下两行(插在带\的任一一行后面即可,查看dockerfile编写规范):
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
[xdebug]
zend_extension=xdebug.so
xdebug.remote_port=9000
xdebug.remote_enable=1
xdebug.remote_host=192.168.0.102
xdebug.remote_autostart=1
xdebug.remote_log="/var/log/dnmp/xdebug.log"
其中192.168.0.102就是你的电脑的IP,也就是docker宿主机的IP,docker的端口都挂到宿主机IP上。xdebug默认是localhost,不改就访问不到了。也不要打开
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings":{
"/var/www/html": "${workspaceRoot}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
发表回复