简体   繁体   English

如何使用PHPStorm调试WordPress主题

[英]How to Debug WordPress theme with PHPStorm

I've installed PHPStorm (8) and trying to debug WordPress theme using xDebug. 我已经安装了PHPStorm(8),并尝试使用xDebug调试WordPress主题。 I tried chrome browser extension and some other settings in the PHP Storm settings. 我尝试了Chrome浏览器扩展程序和PHP Storm设置中的其他一些设置。

I've searched a lot but still unable to attach the page to the debugger. 我进行了很多搜索,但仍然无法将页面附加到调试器。 What I want is to run the code line by line and check variables etc. 我想要的是逐行运行代码并检查变量等。

Can someone tell me what exactly is required so the debugging works? 有人可以告诉我调试所需的确切条件吗?

I've following structure: 我有以下结构:

WAMP is at:  c:\wamp

Project is:  d:\projects\test

alias is: http://localhost/test/

When I opened the project in PHP Storm. 当我在PHP Storm中打开项目时。 It identified it as WordPress project. 它将其标识为WordPress项目。 But it never attaches the browser to debugger. 但是它永远不会将浏览器附加到调试器。

Edit Here is the related xDebug code in php.ini 编辑这里是php.ini中的相关xDebug代码

zend_extension = "c:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9.dll"

[xdebug]
xdebug.remote_enable = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.remote_port = 9000

I also tried true instead of 1 . 我也尝试true而不是1 Also tried without providing any port. 也尝试不提供任何端口。

There seem to be a lot of ways to set up debugging. 似乎有很多方法可以设置调试。 There are browser plugins, and bookmark commands, and all sorts of elaborate setups. 有浏览器插件和书签命令,以及各种复杂的设置。

For the most part, I always want debugging enabled while I'm developing. 在大多数情况下,我总是希望在开发时启用调试功能。 If that's true for you, you might consider adding this to your php.ini file: 如果对您来说是正确的,则可以考虑将其添加到php.ini文件中:

xdebug.remote_autostart = 1

In addition, a key part to my setup is that I have to click the button in the toolbar for " Start Listening for PHP Debug Connections ", and keep this enabled while I work. 另外,设置的关键部分是我必须单击工具栏中的“ 开始侦听PHP调试连接 ”按钮,并在工作时保持启用状态。 This is also in the menus under "Run". 这也位于“运行”下的菜单中。

Have you tried zero-configuration guide for PhpStorm debugger? 您是否尝试过PhpStorm调试器的零配置指南? https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm

I'm using this solution and it works fine. 我正在使用此解决方案,并且效果很好。

Don't forget to add breakpoints and I recommend to create the bookmarklets to activate/deactivate debugger cookies in browser ( https://www.jetbrains.com/phpstorm/marklets/ ). 不要忘记添加断点,我建议创建书签以激活/停用浏览器中的调试器cookie( https://www.jetbrains.com/phpstorm/marklets/ )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM