简化版:有人能否发布一个详细的PHPStorm + XDebug设置指南?假设我非常愚蠢(通常在ASP.NET世界中我已经非常有能力,但是在PHP世界中我接近与海绵动物某些形式相关的智力水平)。 在Windows 7 Ultimate(64位)与IIS&PHP安装的环境中。
使用PhpStorm与Xdebug进行调试非常简单,只需仔细按照此指南操作。(注意: 这里有更新版本的指南)
欲了解更高级的主题,请阅读此文。
php -i
中找出答案。 - CrazyCoder1. 安装 xdebug 模块 (MAC 安装步骤)
1.1.1. 检查你使用的 PHP 版本 php --ini
(查看加载的文件)
1.1.2. brew search xdebug
1.1.3. brew install phpXX-xdebug
1.1.4. 查看细节: php -i | grep xdebug
1.2. 重启服务器
1.3. 配置
1.3.1. sudo find /usr -name 'xdebug.so'
1.3.2. 复制你需要的确切路径
例如: /usr/local/Cellar/php56-xdebug/2.3.2/xdebug.so
1.3.3. 编辑与扩展相关的配置文件,应自动注入主 php.ini:
subl /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini
1.3.4. 添加 zend_extension
为上述复制的路径。
[xdebug]
zend_extension="/usr/local/Cellar/php56-xdebug/2.3.2/xdebug.so"
正常的文件应该长得像这样:
[xdebug]
zend_extension="/usr/local/Cellar/php56/5.6.4/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp"
xdebug.idekey=PHPSTORM
2. 检查您的PHP版本
php --ini
3. 设置IDE设置
首选项 > 语言和框架 > PHP >
3.1. 将语言级别设置为该项目所需的正确PHP版本
3.2. 设置解释器(设置PHP可执行文件的bin目录的父目录)
3.2.1. 点击…按钮 > 点击+按钮 > 其他本地文件 > 设置PHP可执行文件路径,
要查找路径,请在终端中键入:$ which php
例如:/usr/local/Cellar/php56/5.6.5/bin/php
4. 重新启动PhpStorm
5. 现在让我们使其工作
5.1. 运行 > 编辑配置 > 点击左侧的绿色+按钮 > 选择b. PHP Web应用程序
5.2. 名称:任何名称,例如ur {application name - debugger}
5.3. 服务器:localhost(浏览> +> 名称:whatever | 主机:localhost或127.0.0.1)
5.4. 点击确定
5.5. 启动URL:您项目主页的链接:http://127.0.0.1:80/SomethingNew/
5.6. 点击确定
6. 现在设置断点并点击调试
xdebug.remote_enable = on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.show_local_vars=0
然后在顶部导航栏中进入“运行”菜单。然后选择“编辑配置”,并添加新的配置(不要更改另一个项目的默认设置)。
添加新的php Web应用程序后
如果您没有任何服务器(通常在Windows或Linux上将本地主机指向80端口),请单击下面显示的按钮。
添加一个带有xdebug的新服务器。 然后点击确定并检查您的配置。 最后,您将在 IDE 右侧看到配置。 点击“运行”或“调试”按钮。完成了。
您可以在此处找到更详细的“逐步”指南:
https://floyk.com/en/post/how-install-php-with-xdebug-on-mac-os