问题描述
在我的 Laravel 项目 + laradock 中设置 Xdebug 有一个大问题。 我尝试过 PHPStorm 和 VSCode。
我也尝试过使用 Xdebug 3,在 xdebug.ini 上编写相同的设置,但使用新的 Xdebug3 语句。
也许我应该在 WSL 中设置其他东西?
我在 xdebug.ini 上尝试了很多组合,但都没有成功。
在我的配置文件下面:
PHP-fpm/xdebug.ini
xdebug.remote_host="host.docker.internal"
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.cli_color=1
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/PHPstorm/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
PHP-workspace/xdebug.ini
xdebug.remote_host="host.docker.internal"
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.cli_color=1
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/PHPstorm/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
...
WORKSPACE_INSTALL_XDEBUG=true
...
PHP_FPM_INSTALL_XDEBUG=true
...
# Create an account on blackfire.io. Don't enable blackfire and xDebug at the same time. # visit https://blackfire.io/docs/24-days/06-installation#install-probe-debian for more info.
INSTALL_BLACKFIRE=false
###########################################################################
# xDebug:
###########################################################################
ARG INSTALL_XDEBUG=false
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
# Install the xdebug extension
if [ $(PHP -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
pecl install xdebug-2.5.5; \
else \
if [ $(PHP -r "echo PHP_MInor_VERSION;") = "0" ]; then \
pecl install xdebug-2.9.0; \
else \
pecl install xdebug-2.9.8; \
fi \
fi && \
docker-PHP-ext-enable xdebug \
;fi
# copy xdebug configuration for remote debugging
copY ./xdebug.ini /usr/local/etc/PHP/conf.d/xdebug.ini
RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/etc/PHP/conf.d/xdebug.ini && \
sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/PHP/conf.d/xdebug.ini && \
sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/PHP/conf.d/xdebug.ini
laradock/WORKSPACE/Dockerfile
###########################################################################
# xDebug:
###########################################################################
USER root
ARG INSTALL_XDEBUG=false
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
# Install the xdebug extension
if [ $(PHP -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
pecl install xdebug-2.5.5; \
else \
if [ $(PHP -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(PHP -r "echo PHP_MInor_VERSION;") = "0" ]; then \
pecl install xdebug-2.9.0; \
else \
if [ $(PHP -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(PHP -r "echo PHP_MInor_VERSION;") = "1" ]; then \
pecl install xdebug-2.9.8; \
else \
if [ $(PHP -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \
pecl install xdebug-2.9.8; \
else \
#pecl install xdebug; \
echo "xDebug 3 required,not supported."; \
fi \
fi \
fi \
fi && \
echo "zend_extension=xdebug.so" >> /etc/PHP/${laradock_PHP_VERSION}/cli/conf.d/20-xdebug.ini \
;fi
# ADD for REMOTE debugging
copY ./xdebug.ini /etc/PHP/${laradock_PHP_VERSION}/cli/conf.d/xdebug.ini
RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/PHP/${laradock_PHP_VERSION}/cli/conf.d/xdebug.ini && \
sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/PHP/${laradock_PHP_VERSION}/cli/conf.d/xdebug.ini && \
sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/PHP/${laradock_PHP_VERSION}/cli/conf.d/xdebug.ini
laradock/docker-compose.yml
### Workspace Utilities ##################################
workspace:
build:
context: ./workspace
args:
...
- INSTALL_XDEBUG=${WORKSPACE_INSTALL_XDEBUG}
...
### PHP-FPM ##############################################
PHP-fpm:
build:
context: ./PHP-fpm
args:
...
- INSTALL_XDEBUG=${PHP_FPM_INSTALL_XDEBUG}
...
PHPSTORM 设置
窗口设置
PHPINFO()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)