2017-02-21 131 views
0

在Visual Studio代码(1.9.1)(mac)中,我已经设置了php-debug插件。Visual Studio代码 - Xdebug将不起作用

在调试屏幕中,我开始'侦听Xdebug'。
在此之后,我打开我的XAMPP服务器(本地)上的index.php。
但没有任何反应。

  • 屏幕底部的蓝条变为橙色。
  • 步骤结束,步入和退出按钮变灰。
  • 另外,以下错误消息在观看变量发生:
    没有连接

我尝试在下面的代码使用断点无法评估代码:

<?php 
$i = 0; 

do { 
$i++; 
if (!($i % 1)) { 
    echo('<p>$i = ' . $i . '</p>'); 
    } 
} 
while ($i < 100); 
?> 

我使用XAMPP和我的php.ini文件我使用端口9000 Xdebug。

zend_extension="/usr/local/Cellar/php71-xdebug/2.5.0/xdebug.so" 
xdebug.remote_enable = 1 
xdebug.remote_autostart = 1 
xdebug.remote.port=9000 

我使用自制软件安装了Xdebug。
这里是我的PHP信息: phpinfo.htm
Xdebug wizard告诉我Xdebug安装正确。

launch.json文件看起来像这样:

{ 
"version": "0.2.0", 
"configurations": [ 
    { 
     "name": "Listen for XDebug", 
     "type": "php", 
     "request": "launch", 
     "port": 9000, 
     "log": true 
    }, 
    { 
     "name": "Launch currently open script", 
     "type": "php", 
     "request": "launch", 
     "program": "${file}", 
     "cwd": "${fileDirname}", 
     "port": 9000 
    } 
] 
} 

会有人知道我做错了什么?

在ini文件中设置xdebug.remote_connect_back = 1
如n00dl3建议在调试时的大部分时间工作,但一旦我在调试控制台下面
错误:

<- threadEvent 
ThreadEvent { 
    seq: 0, 
    type: 'event', 
    event: 'thread', 
    body: { reason: 'exited', threadId: 1 } } 
+0

你尝试在你的ini文件中设置'xdebug.remote_connect_back = 1'吗? – n00dl3

+0

这似乎工作的大部分时间了,但偶尔我得到在调试控制台以下错误: '< - threadEvent ThreadEvent { 序列:0, 类型:“事件”, 事件:'线程', body:{reason:'exited',threadId:1}}' – Trapce

+0

不知道 – n00dl3

回答

0

似乎所需要的服务器根被设置 在launch.json与localSourceRoot这样的:

{ 
    "version": "0.2.0", 
    "configurations": [ 
     { 
      "name": "Listen for XDebug", 
      "type": "php", 
      "request": "launch", 
      "port": 9000, 
      "log": true, 
      "localSourceRoot": "http://127.0.0.1/public_html/" 
     }, 
     { 
      "name": "Launch currently open script", 
      "type": "php", 
      "request": "launch", 
      "program": "${file}", 
      "cwd": "${fileDirname}", 
      "port": 9000 
     } 
    ] 
} 

现在断点工作就像他们应该。