php phpStorm - 配置 xDebug
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24310201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
phpStorm - configure xDebug
提问by URL87
I try to configure my phpStorm
for debugging according to this tutorial.
我尝试phpStorm
根据本教程配置我的调试。
My entire project is located in C:\work\Projects\xampp\htdocs\myCode
我的整个项目位于 C:\work\Projects\xampp\htdocs\myCode
In the phpStorm
I did to follow -
在phpStorm
我确实遵循 -
Under File > PHP > Servers
:
下File > PHP > Servers
:
Name: myCodeDebug
Host:http://localhost/myCode
Port:80
Debugger:Xdebug
Absolute path on server: http://localhost/myCode
(same as the project location).
服务器上的绝对路径:(http://localhost/myCode
与项目位置相同)。
I use Apache
server in ports 80,443
.
我Apache
在端口中使用服务器80,443
。
My PhpStrom
version is 7.1.3
我的PhpStrom
版本是7.1.3
Now I mark some breakpoints, go to Chrome and navigate to http://localhost/myCode/
but no any phpStrom
debugger is promted although the entire website is got loaded .
现在我标记了一些断点,转到 Chrome 并导航到http://localhost/myCode/
但没有任何phpStrom
调试器被提示,尽管整个网站都被加载了。
What is missed here and how to make it works with xDebug
?
这里遗漏了什么以及如何使其工作xDebug
?
Update:
更新:
Following the suggested in the comments , I followed this tutorialand now I have the chrome extension - Xdebug.
按照评论中的建议,我遵循了本教程,现在我有了 chrome 扩展-Xdebug。
In this manualI paste all the content of php -i
and did all what it required .
在本手册中,我粘贴了 的所有内容php -i
并完成了所需的所有操作。
As described in Xdebug generator, I added two bookmarks - start debug
and stop debug
for IDE key = PHPSTORM
.
正如所描述 的Xdebug发电机,我加了两个书签-start debug
和stop debug
为IDE key = PHPSTORM
。
In my php.ini
I have -
在我的php.ini
我有 -
[XDebug]
xdebug.idekey = "PHPSTORM"
xdebug.remote_port = 80
I work with xampp port 80
.
我与xampp port 80
.
Now I hit the start deebug
bookmark , in the phpStrompress on start to listen to php debug
and set any breakpoint in php scope, set the Xdebug extension on Debug mode , browse to localhost/myCode/index.php
but no any debugging is occur in the phpStrom .
现在我点击start deebug
书签,在phpStrom 中按下start to listen to php debug
并在 php 范围内设置任何断点,在调试模式下设置 Xdebug 扩展,浏览到localhost/myCode/index.php
但在 phpStrom 中没有发生任何调试。
How to config it correctly ?
如何正确配置?
Update 2:
更新 2:
Under cmd
php --version
I have -
在cmd
php --version
我之下-
PHP 5.5.11 (cli) (built: Apr 8 2014 15:07:14)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
Also all in File | Setting | php | servers
was deleted .
也全部File | Setting | php | servers
被删除了。
Update 3:
更新 3:
[Here is my phpinfo();] (personal details had changed to XXXXXXXX) .
[这是我的 phpinfo();](个人信息已更改为 XXXXXXXX)。
回答by Marcin Nabia?ek
The first thing is that in your php.ini it seems you don't have xdebug installed. So first thing is you should go to Xdebug installation guideand paste here your php.ini file so you will get detailed instructions how to install it.
第一件事是在您的 php.ini 中,您似乎没有安装 xdebug。所以第一件事是你应该去Xdebug 安装指南并在这里粘贴你的 php.ini 文件,这样你就会得到如何安装它的详细说明。
If you install it correctly you should have something like below in your php.ini file:
如果您正确安装它,您的 php.ini 文件中应该有如下内容:
The second thing I think is changing your xdebug port. Although your Apache is working at 80 port, for your xdebug you should have set another port.
我认为的第二件事是更改您的 xdebug 端口。尽管您的 Apache 工作在 80 端口,但对于您的 xdebug,您应该设置另一个端口。
In your php.ini you should set for example:
在你的 php.ini 你应该设置例如:
xdebug.remote_port=10000
and of course restart server (I have 9000 port be default be I was getting notification in PhpStorm that this port is busy so I simple changed id to 10000 port).
当然,重启服务器(我有 9000 端口是默认的,因为我在 PhpStorm 中收到通知说这个端口很忙,所以我简单地将 id 更改为 10000 端口)。
Now you should go to your PhpStorm settings and choose PHP -> Servers. You should have here your server and port 80 and you should have here "validate remote environment". Click it and in new Window you should have "Validate" button. You should click it to make sure it's fine. You should have here for example your Xdebug information displayed.
现在您应该转到您的 PhpStorm 设置并选择 PHP -> 服务器。你应该在这里有你的服务器和端口 80,你应该在这里有“验证远程环境”。单击它,在新窗口中您应该有“验证”按钮。你应该点击它以确保它没问题。例如,您应该在此处显示您的 Xdebug 信息。
Now you should in your PhpStorm go to setting (again) and choose PHP -> Debug. Here you need to have the same port as you set in your php.ini file (10000).
现在你应该在你的 PhpStorm 中去设置(再次)并选择 PHP -> Debug。在这里,您需要具有与您在 php.ini 文件中设置的相同的端口 (10000)。
I have the following setting in my PhpStorm in this Debug settings:
在此调试设置中,我的 PhpStorm 中有以下设置:
Now I assume you have your project already open and created some breakpoints. You should click icon "Start listen for PHP Debug connections) in your toolbar - 2nd from debug icon in toolbar.
现在我假设您的项目已经打开并创建了一些断点。您应该单击工具栏中的“开始侦听 PHP 调试连接”图标 - 工具栏中调试图标的第二个。
Now you can go to your browser and if you have your plugin installed correctly and you choose debug and refresh your page in browser, you should get info in your PhpStorm to accept connection to debug and you will be able to debug your site.
现在您可以转到您的浏览器,如果您正确安装了插件并选择调试并在浏览器中刷新页面,您应该在 PhpStorm 中获取信息以接受调试连接,您将能够调试您的站点。
If you still have problem you should also look at http://www.jetbrains.com/phpstorm/marklets/- you may use those instead of using browser addon (simple add generated links to your toolbar/favorites in your browser).
如果您仍然有问题,您还应该查看http://www.jetbrains.com/phpstorm/marklets/- 您可以使用它们而不是使用浏览器插件(简单地将生成的链接添加到您的工具栏/浏览器中的收藏夹)。
What I could also advise you is to look at this PhpStorm xdebug tutorial- it's almost 1 hour but you should be able to learn a lot from it.
我还可以建议您查看此PhpStorm xdebug 教程- 将近 1 小时,但您应该能够从中学到很多东西。
回答by Trick
While not specific to PHPStorm, have you looked through [http://xdebug.org/docs/install#debugclient]? It walks you through step-by-step from installation to debugging code. Plus, it's from the xdebug website so it's a credible source.
虽然不是特定于 PHPStorm,但您是否浏览过 [ http://xdebug.org/docs/install#debugclient]?它会逐步引导您完成从安装到调试代码的过程。另外,它来自 xdebug 网站,所以它是一个可靠的来源。
Starting The DebuggerIn order to enable Xdebug's debugger you need to make some configuration settings in php.ini. These settings are xdebug.remote_enable to enable the debugger, xdebug.remote_host and xdebug.remote_port to configure the IP address and port where the debugger should connect to. If you want the debugger to initiate a session when an error situation occurs (php error or exception) then you also need to change the xdebug.remote_mode setting. Allowed values for this setting are "req" (the default) which makes the debugger initiate a session as soon as a script is started, or "jit" when a session should only be initiated on an error.
启动调试器为了启用 Xdebug 的调试器,您需要在 php.ini 中进行一些配置设置。这些设置是 xdebug.remote_enable 来启用调试器,xdebug.remote_host 和 xdebug.remote_port 来配置调试器应该连接到的 IP 地址和端口。如果您希望调试器在发生错误情况(php 错误或异常)时启动会话,那么您还需要更改 xdebug.remote_mode 设置。此设置的允许值是“req”(默认值),它使调试器在脚本启动后立即启动会话,或“jit”(仅应在出现错误时启动会话时)。
It's got lots of configuration settings, tips, and general help to get you up and running. It also provides links to several browser interfaces for Xdebug, including (what claims to be) the easiest to use (Firefox), The easiest Xdebug. There's also plugins for Chrome, Safari, and Opera.
它有许多配置设置、提示和一般帮助,可帮助您启动和运行。它还为 Xdebug 提供了几个浏览器界面的链接,包括(声称是)最容易使用的(Firefox),最简单的 Xdebug。还有适用于 Chrome、Safari 和 Opera 的插件。
Let me know if you need any further help.
如果您需要任何进一步的帮助,请告诉我。
Again, may not be specific to your IDE, but it may point you in the right direction,
同样,可能不是特定于您的 IDE,但它可能会为您指明正确的方向,
回答by Evan Darwin
According to your phpinfo() output, you don't have the XDebug plugin loaded (for Apache). So while it may show up when you run PHP from the command line, it doesn't show up for when you access it through Apache.
根据您的 phpinfo() 输出,您没有加载 XDebug 插件(用于 Apache)。因此,当您从命令行运行 PHP 时它可能会出现,但当您通过 Apache 访问它时它不会出现。
There is a difference between the mod_php for Apache and the PHP command line. There are different php.ini files for the CLI and Apache versions, so you'll need to find the Apache version and add something like the following at the end:
Apache 的 mod_php 和 PHP 命令行之间存在差异。CLI 和 Apache 版本有不同的 php.ini 文件,因此您需要找到 Apache 版本并在末尾添加如下内容:
zend_extension=C:\path\to\xdebug.dll
[xdebug]
xdebug.idekey = "PHPSTORM"
xdebug.remote_enable = 1
xdebug.connect_back = 1
If you need some more information, PhpStorm itself provides a useful getting started guide, and that's available here.
如果您需要更多信息,PhpStorm 本身提供了有用的入门指南,可在此处获得。
回答by Kevin Nelson
XDebug should be sending data over port 9000--the default--unless you have something else running on port 9000, and PhpStorm should be set to listen on the same port. This is how they are by default, so just don't change them. Port 80 is for your web server, not for XDebug to communicate w/ PhpStorm. If you have it on port 80, your web server is already there and XDebug won't be able to communicate with PhpStorm.
XDebug 应该通过端口 9000 发送数据——默认值——除非你在端口 9000 上运行其他东西,并且 PhpStorm 应该设置为在同一端口上侦听。这是默认情况下的方式,所以不要更改它们。端口 80 用于您的 Web 服务器,而不是用于 XDebug 与 PhpStorm 通信。如果您在端口 80 上安装它,则您的 Web 服务器已经在那里,XDebug 将无法与 PhpStorm 通信。
You need to change this in your PhpStorm settings and maybe in XDebug configuration if you modified that.
您需要在您的 PhpStorm 设置中更改此设置,如果您修改了它,则可能在 XDebug 配置中进行更改。