2017-02-21 54 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 
     } 
    ] 
} 

現在斷點工作就像他們應該。