如何使用phpstorm和xdebug设置symfony2的远程调试 [英] How to set up remote debugging for symfony2 with phpstorm and xdebug

查看:483
本文介绍了如何使用phpstorm和xdebug设置symfony2的远程调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:




  • 我想要调试我的symfony2项目。我想要
    能够在我的代码中设置一个断点,运行远程调试,并且
    能够在我的应用程序中与
    进行交互时,通过代码中的所有断点。



背景信息和当前设置




  • 我使用的IDE是phpstorm。


  • Apache和mySql服务器正在我的vmware播放器上运行。


  • 安装Xdebug在vmware播放器上。


  • 我目前通过我的vmware播放器ip
    连接到我的项目(即172.16.48.1/app_dev.php)。在这一点上,我通常和我的
    应用程序进行交互。




到目前为止




  • 我按照教程,但没有任何运气。


  • 我真的很困惑,大部分的教程,但最好尽可能遵循它。我不认为按照说明书,书签工作正常。


  • 我也看过一个网络研讨会或两个远程调试,但还不完全清楚我需要做些什么来完成我的代码。




问题: p>


  • 有人可以提供一步一步的教程,我需要做的是
    设置远程调试,以便我可以启动一些远程调试
    会话通过phpstorm将打开我的网络应用程序和作为我
    浏览我的网络应用程序我的断点将被打击?


解决方案

我刚刚完成了Chrome的本地symfony2应用和phpstorm调试,这里是我所做的:



1)在服务器上的php.ini中配置xdebug并重新启动Web服务器(或php-fpm):

  [xdebug] 
zend_extension =**位置到xdebug ** / xdebug.so
xdebug。 remote_enable = 1
;使用端口9009,因为php-fpm默认使用9000
xdebug.remote_port = 9009
xdebug.idekey = PHPSTORM

2)安装xdebug扩展名
https: //chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc



3)安装xdebug exteions。在chrome:// extensions中找到Xdebug帮助和点击选项。选择IDE键到PhpStorm。 (这将基本上将xdebug.idekey设置为该特定会话的PHPSTORM)



4)现在是从PhpStorm连接的最棘手的部分。
您必须设置 PHP远程调试调试配置。


  1. 工具栏旁边的调试按钮,您有第一个选项编辑配置的下拉字段。它会打开运行/调试配置

  2. 点击 + 按钮添加 PHP远程调试

  3. 指定您的姓名,服务器和 Ide键 = PHPSTORM

  4. 单击应用并确定(我永远不知道哪一个,所以我总是单击两个,以防万一)

  5. 现在,工具栏中的下拉菜单将显示您新设置的远程服务器,运行按钮(绿色箭头)将被禁用。

  6. 点击开始听PHP调试连接

  7. 点击绿色的错误图标开始调试

  8. 调试视图将打开2个选项卡:调试器和控制台(默认选择)

  9. 将选项卡更改为调试器,您将看到:等待与ide键PHPSTORM的传入连接

  10. 打开浏览器

  11. 导航到您的服务器url

  12. 激活Xdebug辅助扩展(点击URL栏中的灰色错误)将绿色

  13. 变为c确认一切正常,打开Chrome控制台,选项卡资源 - > Cookie - >您的服务器。并验证是否创建了具有值PHPSTORM的cookie XDEBUG_SESSION(这是实际激活PHP中的xdebug远程调试)

  14. 现在刷新页面,并快速将其替换为PhpStorm(或安排您的窗口所以您可以在调试视图和Debugger控制台中查看PhpStorm,同时刷新浏览器)

  15. 您将简要地看到已连接

TADA!



在控制器中创建几个断点(不要使用AppKernel.php或其他symfony2特定文件,因为这些文件被编译并且不被调用,甚至在开发模式)






添加5.1.2015



官方教程可以在这里找到:
https://confluence.jetbrains.com/display/PhpStorm/Profiling+PHP+applications+with+PhpStorm+and+Xdebug


Problem:

  • I want to be able to debug my symfony2 project. I would like to be able to set a break point in my code, run remote debugging and be able to step through all the break points in my code as I interact with my application.

Background information and current setup:

  • The IDE I am using is phpstorm.

  • Apache and mySql server are running on my vmware player.

  • Xdebug is installed on vmware player.

  • I currently connect to my project through my vmware players ip (i.e 172.16.48.1/app_dev.php). At this point I interact with my application normally and develop.

What I have done so far

  • I followed the tutorial but have not had any luck.

  • I really confused by most of the tutorial but followed it as best as I could. I do not think the bookmarklets were working correctly when following the instructions.

  • I also watched a webinar or two on remote debugging and it still was not completely clear to me what I need to do to step through my code.

Question:

  • Can someone provide a step by step tutorial of what I need to do to setup remote debugging so that I can launch some remote debugging session through phpstorm that will open my web application and as I navigate through my web application my break points will be hit?

解决方案

i've just finished setting up my local symfony2 app and phpstorm debugging with Chrome, here is what i've done:

1) config xdebug in php.ini on the server and restart web server (or php-fpm):

[xdebug]
zend_extension="**location to xdebug**/xdebug.so"
xdebug.remote_enable = 1
; use port 9009 because php-fpm uses 9000 by default
xdebug.remote_port = 9009
xdebug.idekey = PHPSTORM

2) install xdebug extension https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc

3) setup xdebug exteions. in chrome://extensions find Xdebug helper and click options. there select IDE key to PhpStorm. (this will essentially set xdebug.idekey to PHPSTORM for that particular session)

4) now the trickiest part, connecting from PhpStorm. you have to setup PHP Remote Debug debug configuration.

  1. in the toolbar, next to the debug button, you have drop down field with the first option Edit configuration. it opens Run/Debug Configurations.
  2. there click the + button and add PHP Remote Debug.
  3. specify your name, server and Ide key = PHPSTORM.
  4. click Apply and Ok (i never know which one so i always click both, just in case)
  5. now the dropdown in the toolbar will show your newly set remote server, run button (green arrow) will be disabled.
  6. click Start Listen for PHP Debug Connection
  7. click that green bug icon to start debugging
  8. Debug view will open with 2 tabs: Debugger and Console (selected by default)
  9. change the tab to Debugger and you will see: "Waiting for incoming connection with the ide key 'PHPSTORM'"
  10. open your browser
  11. navigate to your server url
  12. activate Xdebug helper extension (clicking on that gray bug in the url bar) it will turn green
  13. to check that everything is ok, open Chrome console, tab Resources -> Cookies -> your server. and verify that cookie XDEBUG_SESSION with value PHPSTORM was created (this is what actually activates xdebug remote debugging in php)
  14. now refresh the page and quickly alt-tab back to PhpStorm (or arrange your windows so you can see PhpStorm while refreshing browser)
  15. in your Debug view and Debugger console you will briefly see "Connected"

TADA!

create couple of break points in controller (dont use AppKernel.php or other symfony2 specific files as those get compiled and are not called, even in dev mode)


added 5.1.2015

official tutorial can be found here: https://confluence.jetbrains.com/display/PhpStorm/Profiling+PHP+applications+with+PhpStorm+and+Xdebug

这篇关于如何使用phpstorm和xdebug设置symfony2的远程调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆