開發環境描述,windows10+docker+php7.4+phpstrom。
Dockerfile 設定
RUN apt -y install php-pear php-dev libmcrypt-dev
# xdebug
RUN pecl install xdebug
For xdebug 2.X php.ini settings
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
For xdebug 3.X php.ini settings
[xdebug]
xdebug.mode=debug
xdebug.client_host=host.docker.internal
xdebug.client_port=9000
xdebug.idekey=PHPSTORM
PHPSTORM PHP Xdebug settings
- File > Settings > Languages & Frameworks > php > Debug
Xdebug -> Debug port: 9000 (必須與xdebug.remote_port或xdebug.client_port一致)
-
Run > Edit Configurations...
-
"+" > PHP Remote Debug
[如果沒有Server可以選擇,請參考PHPSTORM PHP Servers settings設定]
PHPSTORM PHP Servers settings
啟用 [V] Use path mappings (select if the server is remote or symlinks are used)
注意 File/Directory 與 Absolute path on the server 的 Project files path
#include <stdio.h>
int main()
{
printf("Hello C!\n");
return 0;
}