简体   繁体   English

phpstorm xdebug与symfony2项目

[英]phpstorm xdebug with a symfony2 project

I am trying to debug a symfony2 application with xdebug and phpstorm. 我正在尝试使用xdebug和phpstorm调试symfony2应用程序。

My local development environment is Ubuntu 14.04 with apache2 and Xdebug version is 2.2.7 我的本地开发环境是Ubuntu 14.04,apache2,Xdebug版本是2.2.7

I have this working on another php (not symfony2) projects with the following guides: 我有这个工作在另一个PHP(而不是symfony2)项目与以下指南:

https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html

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

When I execute the bookmarlet to set the cookie and start debugging this symfony2 project phpstorm detects the incoming connection (which I accept), but nothing else happens. 当我执行bookmarlet设置cookie并开始调试这个symfony2项目时,phpstorm检测到传入连接(我接受),但没有其他事情发生。 It doesn't stop in any breakpoint. 它不会在任何断点处停止。

I have the symfony2 phpstorm plugin. 我有symfony2 phpstorm插件。 I tried to disable it and get nothing as well. 我试图禁用它,也没有得到任何东西。

This answer looked good to me, but it didn't the trick either 这个答案看起来对我很好,但它也没有

Last thing I tried is to change the Servers debug configuration, disabling path mappings. 我尝试的最后一件事是更改服务器调试配置,禁用路径映射。 This way phpstorm starts debugging, but it breaks in app_dev.php file instead of any breakpoint I have set. 这样phpstorm开始调试,但它在app_dev.php文件而不是我设置的任何断点中断。

I am stuck here, any idea would be appreacite 我被困在这里,任何想法都将是appreacite

UPDATE UPDATE

More information I didn't mention: 更多信息我没有提到:

  • I am using firefox I am trying to debug dev environment 我正在使用firefox我正在尝试调试开发环境
  • Breakpoints are in an action in controller of my own, not vendor ones. 断点是我自己的控制器中的一个动作,而不是供应商的动作。

UPDATE UPDATE

Here is my xdebug configuration 这是我的xdebug配置

[XDebug]
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port="9000"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="<AMP home\tmp>"

I don't know which browser you are using, but, using Chrome, I use the Xdebug helper extension. 我不知道您使用的是哪种浏览器,但是,使用Chrome,我使用的是Xdebug助手扩展程序。

Once the extension is installed, right click on it > options and select PHPStorm as IDE. 安装扩展后,右键单击它>选项,然后选择PHPStorm作为IDE。

Then, start listening for connection on PHPStorm using the button near the debug one. 然后,使用调试附近的按钮开始在PHPStorm上监听连接。

EDIT : 编辑

Here is my configuration of XDebug: 这是我的XDebug配置:

zend_extension=/usr/lib/php5/20121212/xdebug.so
xdebug.max_nesting_level = 1000
xdebug.collect_params = 1
xdebug.collect_return = 1
xdebug.remote_enable = 1

Are you sure XDebug is properly installed on your machine ? 您确定XDebug已正确安装在您的计算机上吗?

When in PHPStorm > Run > Edit Configurations... , add a PHP Web Application debugging profile and fill it this way: PHPStorm > Run > Edit Configurations... ,添加PHP Web应用程序调试配置文件并以这种方式填写:

  • Name : Acme Project 名称 :Acme项目
  • Server : apache2 (you might need to add yours - name, port, adresse, debugger) 服务器 :apache2(您可能需要添加自己的名称 - 名称,端口,地址,调试器)
  • Start URL : /app_dev.php 起始网址 :/app_dev.php
  • Browser : Default 浏览器 :默认

Press OK and you're done ! 按确定即可完成!

I had a similar issue which again proved to be a mapping problem, debugging a Symfony 2 project remotely using PHPStorm. 我有一个类似的问题再次被证明是一个映射问题,使用PHPStorm远程调试Symfony 2项目。

If PHPStorm can't map the src file locations, it will break on the first line of code in app_dev.php (if you've set 'Break on first line') but then continue straight through any break points set in /src (eg Controllers, Models, etc.) and doesn't flag any error. 如果PHPStorm无法映射src文件位置,它将在app_dev.php的第一行代码中断(如果你设置了'Break on first line'),然后继续直接通过/ src中设置的任何断点(例如控制器,型号等)并且不标记任何错误。

  1. Go to Setting -> Languages & Frameworks -> PHP -> Servers 转到设置 - >语言和框架 - > PHP - >服务器
  2. Select your server in the middle-left pane (or add using '+') 在左中窗格中选择您的服务器(或使用'+'添加)
  3. Check 'Use path mappings (select if the server is remote or symlinks are used)' 选中'使用路径映射(选择服务器是远程服务器还是使用符号链接)'
  4. Add mappings such that /app, /src and /web are mapped. 添加映射以映射/ app,/ src和/ web。 These can be individual mappings, but it's better if possible to set a higher level mapping on / which covers them all. 这些可以是单独的映射,但如果可能的话,更好地设置更高级别的映射/覆盖它们。

Once PHPStorm can map these paths, it stops and breakpoints and meaningful debugging can begin. 一旦PHPStorm可以映射这些路径,它就会停止和断点,并且可以开始有意义的调试。

It was a mapping problem. 这是一个映射问题。 The following are the steps which did the trick 以下是完成这一操作的步骤

  1. Disable path mapping under Settings > Languages & Frameworks > PHP > Servers > uncheck "Use path mappings 在“设置”>“语言和框架”>“PHP”>“服务器”>“取消选中”“使用路径映射”下禁用路径映射
  2. Start debugging 开始调试
  3. The famous “Remote file path 'path/to/script/on/the/server.php' is not mapped to any file path in project“ finally appears 着名的“远程文件路径”路径/ to / script / on / the / server.php'未映射到项目中的任何文件路径“最终出现
  4. Then I could follow the Troubleshooting section in official guide setting up path mappings 然后我可以按照官方指南中的故障排除部分设置路径映射

Hope this helps to anyone else 希望这对其他人有帮助

If you find that PHPStorm keeps asking for mappings try and create a mapping at the highest level of the project as @stanhope mentioned, that should be enough. 如果您发现PHPStorm不断要求映射,请尝试在@stanhope提到的项目的最高级别创建映射,这应该足够了。

My first mapping was incorrectly set to the app_dev.php file in /web which meant that the IDE kept asking me for mappings to files in vendor directories. 我的第一个映射被错误地设置为/ web中的app_dev.php文件,这意味着IDE一直要求我映射供应商目录中的文件。

eg /vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Response.php 例如/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Response.php

在此输入图像描述

I also had to comment out the loading of class cache (symfony 2.7). 我还必须注释掉类缓存的加载(symfony 2.7)。 I did it temporarily in the web/app_dev.php 我暂时在web/app_dev.php

//$kernel->loadClassCache();

Otherwise the debugging took place in bootstrap.php.cache or breakpoints did not work. 否则调试发生在bootstrap.php.cache或断点不起作用。

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

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