dbalabka/phpdebug-cli

XDebug 和 Zend Debugger PHP CLI 调试助手控制台命令,支持 PhpStorm 和 NetBeans

安装: 2

依赖: 0

建议: 0

安全: 0

星标: 10

关注者: 2

分支: 1

开放问题: 3

语言:Shell

dev-master 2020-05-07 09:07 UTC

This package is auto-updated.

Last update: 2024-09-07 18:43:29 UTC


README

XDebug PHP CLI 调试助手控制台命令,支持 PhpStorm 和 NetBeans

安装步骤

  1. 将文件下载到 ~/.phpdebug,运行以下命令
    curl https://raw.githubusercontent.com/torinaki/phpdebug-cli/master/phpdebug.sh > ~/.phpdebug
  2. 将以下行放入 ~/.bashrc
    # Get the aliases and functions
    if [ -f ~/.phpdebug ]; then
        . ~/.phpdebug
    fi
  3. (可选) 脚本将尝试自动检测运行 IDE 的机器 IP,如果没有成功,则使用 127.0.0.1。如果自动检测对您不起作用,请通过 IDE_IP 环境变量直接设置 IP
    export IDE_IP=1.2.3.4
  4. (可选) 如果端口与默认端口不同,请更改端口(参见局部变量 zend_debugger_config 和 xdebug_config);
   export IDE_ZEND_PORT=10137
   export IDE_ZDEBUG_PORT=9000
  1. (可选) 更改 IDE 特定配置:serverName,idekey
   export IDE_SERVERNAME="Any_server_name"
   export IDE_KEY="PHPSTORM"
  1. 运行后立即使用或仅重启终端
   source ~/.bashrc

用法

  1. 安装后,使用 phpdebug/phpdebugoff 命令启动/停止调试
  $ phpdebug
  $ php ./script1_to_debug.php
  $ php ./script2_to_debug.php
  $ phpdebugoff
  1. 或者简单地使用代替 php 命令来调试单个脚本
  $ phpdebug -dmemory_limit=1G ./script_to_debug.php

配置选项

您可以使用环境变量来更改默认配置

export IDE_ZEND_PORT=10137
export IDE_XDEBUG_PORT=9000
export IDE_KEY="PHPSTORM"
export IDE_SERVERNAME="$(hostname)"
# SSH client IP will be autodetected by default
export IDE_IP="1.2.3.4"