我无法让我的 PhpStorm IDE 与 xdebug 一起工作。
我目前的设置如下:
- PhpStorm 2017.1.4
- MacOS Sierra 10.12.5
这是我遵循的步骤。
我已经使用以下命令安装了 php。我添加了 postgres 参数,因为稍后我需要它来连接到 PostgreSQL 数据库。
brew install php71 --with-postgresql
下一步是使用以下命令安装 XDebug
brew install php71-xdebug
因此,我从文档 (https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html) 中获得的下一步是使用以下内容编辑 php.ini 文件:
[Xdebug]
zend_extension="<path to php_xdebug.dll>"
xdebug.remote_enable=1
xdebug.remote_port="<the port for Xdebug to listen to>" (the default port is 9000)
xdebug.profiler_enable=1
xdebug.profiler_output_dir="<AMP home\tmp>"
只是关于这些字段和 XDebug 的一些问题。
- 所以我猜 XDebug 是在
remote_port
上运行的某种服务那个 PhpStorm 正在用来写入数据?或者您是否必须指定要测试的应用程序运行的端口? - 分析器到底是什么东西?输出目录可以是我可以选择的任何内容吗?
所以这是我的 php.ini 文件,我认为它应该是:
[xdebug]
zend_extension="/usr/local/Cellar/php71-xdebug/2.5.4/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/usr/tmp"
这就是 php.ini 的内容。所以我必须检查我的 PhpStorm IDE 中的设置。这些是:
这就是我的设置。在我的项目中,我只有一个 index.php
与 <?php echo phpinfo(); ?>
我只需单击 Chrome 图标,它就会直接在浏览器中打开,以检查 XDebug 是否存在。我看到以下结果。
所以我心想,好吧,让我们尝试一些调试。所以我改变了我的 index.php
文件到下面
$i = 2;
$j = $i + 2;
echo $j
我在第二行设置了一个断点。当我运行它时,它永远不会在断点处停止。需要做什么,或者我在某个地方的配置有误?
最佳答案
要让Xdebug远程调试你的页面,你需要在你的浏览器中设置一个cookie,告诉服务器你要调试这个页面,有很多扩展,最有名的是Xdebug helper。在 Chrome 中。
我还建议您遵循本教程 Zero-configuration debugging , IMO 非常详细和清晰。
如果您还有问题,我会尽力帮助您:)
关于php - 将 xdebug 与 PhpStorm 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44414321/