php - 无法使用 Laradock + PHP 7.2 + PhpStorm/VSCode + Xdebug 2.9.8/Xdebug 3.0.3 与 WSL 的 Laravel 项目一起为任何 IDE 设置 Xdebug
问题描述
我在我的 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
LARADOCK/PHP-FPM/Dockerfile
###########################################################################
# 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/工作空间/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}
...
窗口设置
PHPINFO()
解决方案
推荐阅读
- r - 按年份分类变量的 R 到 Latex 汇总表
- html - 没有文本框的 HTML 输入标签
- python - 如何将解包运算符(“*”)与 C 风格的字符串格式一起使用?
- r - 对列名中具有相同字符串的列应用相同的操作?
- verilog - 每当我运行 vvp 命令时出现 Verilog 语法错误
- ubuntu - Apache 配置不同的主机应用程序使用相同的 IP 和相同的端口
- google-chrome-extension - 2021 年在 chrome 扩展中模板化有哪些不错的选择
- sql-server - 从 ODBC C API 获取套接字文件描述符
- nginx - 使用 pm2 和 nginx 将 Nuxt SSR 部署到域上的子目录
- mysql - MySQL插入失败