在wordpress镜像中增加xdebug功能

前言

修改官方的wordpress镜像,增加xdebug插件功能。

问题

docker环境中,官方的wordpress默认没有xdebug功能,重新编译dockerfile,支持该功能。

解决过程

1、xdebug的原理了解。

image

xdebug是php的扩展,会搜集php执行的信息,然后发送给指令的远程ip+port。这里通常我们使用的开发工具会监听某个port。接受到php执行信息。再debug界面进行显示。

2、首先需要安装xdebug扩展。
这里我们是基于docker的php环境。在php的dockerfile文件中添加如下语句。

RUN pecl install xdebug && docker-php-ext-enable xdebug

增加xdebug的配置。

[xdebug]

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=192.168.18.1
xdebug.remote_port=9000
xdebug.idekey=phpStorm
xdebug.remote_autostart=1
xdebug.remote_connect_back = 1
xdebug.auto_trace = 1
xdebug.collect_includes = 1
xdebug.collect_params = 1
;xdebug.remote_log = /tmp/xdebug.log

3、IDE的配置

  • 配置好远程服务器上的php.ini,里面的【xdebug】
  • 在浏览器中安装扩展:Firefox、Chrome中名称为


    image.png
  • 设置phpstorm参数


    image.png
  • 开启监听


    image.png
  • 同步好远程和本地的目录


    image.png
  • 浏览器中将扩展开关打开,ide中加断点,可以调试了。
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容