doumin1897 2016-04-17 17:03
浏览 1743
已采纳

如何使用VS Code启动和调试php?

I'm new to VS Code and the php world. My experience is more with heavyweight IDE such as Visual Studio. However, I have a need to setup a php environment on my dev machine and am having some trouble getting it to work properly.

My environment is a Win 10 dev machine. I am using VS Code and php ver 5.5. I have properly installed the xdebug extension and verified it is properly installed. I have also installed the php-debug extension in VS Code.

The challenge I'm having and have been unable to find any useful information through google is launching the php website from within VS Code and then being able to debug it.

A few things I have tried, but haven't worked.

  1. I installed the iis-express extension to VS Code which allows for running any folder through iis express. https://marketplace.visualstudio.com/items?itemName=warren-buckley.iis-express This works, but the website doesn't display properly. IIS returns an error message saying the site is not properly configured. It's apparently missing a mapping or something along those lines.

  2. I followed this blog. http://blog.denouter.net/2015/05/run-php-from-visual-studio-code.html and am able to run the website using the built in php web server.

  3. Installed webmatrix and let the windows platform installer correctly install and wire up iis express to work with php. The same folder works fine when running from webmatrix.

  4. Installed the php-debug extension to VS Code. https://github.com/felixfbecker/vscode-php-debug

Here is what I think I'm missing. I believe I need to launch the website from within VS Code for the debugging to work. I can't figure out how to "launch" the php website from within VS Code. The php-debug extension from VS Code only supports launch. It doesn't support "attach" mode. I suspect this is why when I run the website outside VS Code, the debugger doesn't work. Let me be clear, the debugger is working when I hit F5, it just doesn't ever stop on any breakpoints.

To summarize: How can I launch and debug my php website from within VS Code? I'm looking for a detailed step by step guide.

Thank you

  • 写回答

1条回答 默认 最新

  • dongshi6528 2016-06-22 11:35
    关注

    I am the author of vscode-php-debug. You do not need to "launch the website" from inside VS Code. When you start the "Listen for XDebug" configuration from the debug section, VS Code (or rather, my debug adapter) will listen on port 9000 for XDebug. You need to run a web server like Apache, IIS or nginx locally on your PC and configure it to serve PHP files - this has nothing to do with VS Code. Then simply open a web browser and navigate to localhost and XDebug will connect to the debugger, stopping on breakpoints.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用