装置xdebug

macos环境下,默认你曾经装置了php和pecl,pecl是php下装置php扩大的一种工具,这里我应用的php7.3

  1. 执行以下命令装置xdebug扩大:
    pecl install xdebug
  2. 装置实现后执行:
    php -v
    而后你会看到相似以下返回信息:

    PHP 7.3.20 (cli) (built: Jun  4 2021 03:32:07) ( NTS )  Copyright (c) The PHP Group  Zend Engine v3.4.0, Copyright (c) Zend Technologies   with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans   with Zend OPcache v7.3.20, Copyright (c), by Zend Technologies

    看到xdebug阐明装置胜利了,装置胜利门路相似是:
    /usr/local/lib/php/pecl/20180731/xdebug.so

  3. 更新php.ini文件,门路相似:
    /usr/local/etc/php/7.3/php.ini
    复制如下内容到文件开端,这里我应用的是9003端口,如果你应用其余端口,记得批改,否则可能无奈监听到变动:

    ; Make sure this is the only line which assign `zend_extension` to `xdebug.so`zend_extension = /usr/local/lib/php/pecl/20190902/xdebug.so[xdebug]xdebug.start_with_request=yesxdebug.mode=debugxdebug.client_host = 127.0.0.1xdebug.client_port = 9003xdebug.show_exception_trace = Onxdebug.remote_handler = dbgp

VSCode设置

  1. 装置php debug扩大
  2. 设置php debug配置文件,这里端口要和php.ini里的端口统一
  3. 开始调试,记得这里要去网页端申请localhost:9003能力执行