相逢一定曾相识 發表於 2019-9-19 22:07:00

vscode配置PHP Debug

<p><span style="font-size: 18px">1、先在vscode中安装PHP Debug,在设置添加“</span>php.validate.executablePath<span style="font-size: 18px">”项,选中对应版本的php.exe。</span></p>
<p>&nbsp;</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">php.validate.executablePath</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">d:\\wamp\\bin\\php\\php7.2.14\\php.exe</span><span style="color: rgba(128, 0, 0, 1)">"</span>,</pre>
</div>
<p>&nbsp;</p>
<p><span style="font-size: 18px">2、按F5调试,选择PHP,就可以了,可能会配置失败。</span></p>
<p><span style="font-size: 18px">3、按 Ctrl+Shift+D 打开调试面板,点击上面的小齿轮打开launch.json,如果出现“</span>Listen&nbsp;for&nbsp;XDebug<span style="font-size: 18px">”和“</span>Launch&nbsp;currently&nbsp;open&nbsp;script<span style="font-size: 18px">”,就证明成功了,</span></p>
<p><span style="font-size: 18px">可以调试了。</span></p>
<p><span style="font-size: 18px">4、如果发现没有,就需要手动添加了:</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">{
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 使用 IntelliSense 了解相关属性。
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 悬停以查看现有属性的描述。
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 欲了解更多信息,请访问: </span><span style="color: rgba(0, 128, 0, 1); text-decoration: underline">https://go.microsoft.com/fwlink/?linkid=830387</span>
<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">version</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">0.2.0</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">configurations</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">: [
    {
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">name</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Listen for XDebug</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">type</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">php</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">request</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">launch</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">port</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 128, 1)">9000</span><span style="color: rgba(0, 0, 0, 1)">
    },
    {
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">name</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Launch currently open script</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">type</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">php</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">request</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">launch</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">program</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">${file}</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">cwd</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">${fileDirname}</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">port</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 128, 1)">9000</span><span style="color: rgba(0, 0, 0, 1)">
    }
]
}</span></pre>
</div>
<p><span style="font-size: 18px">5、然后在随便一个页面输出一下phpinfo(); Ctrl+A 复制页面的内容到&nbsp;https://xdebug.org/wizard.php&nbsp;的文本框内,点击下面的 Analyse my phpinfo() output 按钮获取对应的xdebug.dll文件,下载下来放到当前版本php目录下的zend_ext文件夹内。</span></p>
<p><span style="font-size: 18px"><img src="https://img2018.cnblogs.com/blog/1235146/201909/1235146-20190919220122046-133045681.png"></span></p>
<p><span style="font-size: 18px"><img src="https://img2018.cnblogs.com/blog/1235146/201909/1235146-20190919220146340-339096036.png"></span></p>
<p><img src="https://img2018.cnblogs.com/blog/1235146/201909/1235146-20190919220239963-706087637.png"></p>
<p><img src="https://img2018.cnblogs.com/blog/1235146/201909/1235146-20190919220256255-577758662.png"></p>
<p><span style="font-size: 18px">6、配置apache下的php.ini文件</span></p>
<div class="cnblogs_code">
<pre>D:\wamp\bin\apache\apache2.<span style="color: rgba(128, 0, 128, 1)">4.37</span>\bin\php.ini</pre>
</div>
<p><span style="font-size: 18px"></span><br><span style="font-size: 18px">zend_extension = "D:/wamp/bin/php/php7.2.14/zend_ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll" :对应下载的xdebug的目录</span><br><span style="font-size: 18px">xdebug.remote_enable = 1</span><br><span style="font-size: 18px">xdebug.remote_autostart = 1</span><br><span style="font-size: 18px">xdebug.remote_handler=dbgp</span><br><span style="font-size: 18px">xdebug.remote_mode=req</span><br><span style="font-size: 18px">xdebug.romote_host=localhost</span><br><span style="font-size: 18px">xdebug.remote_port=9000 //关键在于这个端口号要和launch.json配置的端口号对应起来。</span></p>
<p>&nbsp;</p>
<p><span style="font-size: 18px; color: rgba(255, 0, 0, 1)">然后重启服务器就ok啦。</span></p><br><br>
来源:https://www.cnblogs.com/xinchenhui/p/11552917.html
頁: [1]
查看完整版本: vscode配置PHP Debug