美文网首页程序员
PhpStorm+Xdebug+Docker实现断点调试(Mac

PhpStorm+Xdebug+Docker实现断点调试(Mac

作者: ysnows | 来源:发表于2018-03-14 23:11 被阅读195次

    PhpStorm+Xdebug+Docker实现断点调试(Mac平台亲测)

    1. 配置xdebug

    [xdebug]
    zend_extension=xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_handler=dbgp
    xdebug.remote_port=9001
    xdebug.remote_autostart=1
    xdebug.remote_connect_back=0
    xdebug.idekey=PHPSTORM
    xdebug.remote_host=127.0.0.1

    ```
    
    1. 设置docker的环境变量XDEBUG_CONFIG,并运行docker run -p 9000:9000 --name php-fpm -v $PWD/www:/var/www/html -v $PWD/php/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf -v $PWD/php/conf:/usr/local/etc/php -e XDEBUG_CONFIG="remote_host=192.168.31.5" -d ysnows/php7.2.3-fpm:latest,其中,remote_host就是运行phpstorm那台机器的ip地址,mac可通过ifconfig en0获取

      image
    2. 配置PhpStorm,如图

      1. image
      2. image
    3. 安装xdebug_helper插件,并配置为PhpStorm

      image
    4. 开启插件的debug功能


      image
    1. 打断点,访问,愉快的调试


      image
    image

    参考:
    1. Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

    1. 以上是在浏览器中访问的时候,进行断点调试;还有一个需求是,在php index.php运行命令行的时候进行调试,解决方案:

      1. 建立Server
        image
      2. 设置Docker镜像的环境变量


        image
      3. Start Listenning


        image
      4. index.php中添加断点,并在Docker容器中运行php index.php即可断点调试

    相关文章

      网友评论

        本文标题:PhpStorm+Xdebug+Docker实现断点调试(Mac

        本文链接:https://www.haomeiwen.com/subject/jetcqftx.html