Научите пользоваться дебагером

Добрый день/вечер.

Такое ощущение, что что-то делаю не так (или ожидаю не того).

Научите пожалуйста пользоваться дебагером в phpstorm 1.0.1
Можно (желательно) с картинками.

Xdebug настроен, и отладка локального файла идет нормально, а вот с удаленнным какая-то ерунда.

Я ожидал что браузер будет отрисовывать данные по шагам, а это не происходит.

Также мне непонятно как отладить к примеру вызов PHP через AJAX.
Я наивно полагал, что достаточно поставить на нужном файле точку остановки и нажать debug на имени проекта :(

Сперва ругались на server path mapping - настроил. Хотя почему нельзя его было создать из существующей информации о проекте?

Браузер запускается - The connection was reset.
Включаем галочку break at the first line - включается отладка индексного файла, браузер думает.
Доходим до конца - в браузере вместо информации - The connection was reset.


Что я делаю не так?

ну и пока мучался накопал:
http://youtrack.jetbrains.net/issue/WI-2586
http://youtrack.jetbrains.net/issue/WI-2194
(это чтоб меня тунеядцем не посчитали :) )

6 comments
Comment actions Permalink

Hello Marat,

Sorry for delay,

We will publish PHP debugging screencast soon, please watch our site.

Here are general steps on setting up the debugging, but it seems that you've already done them, since your breakpoints are triggered:

First you need to set up a server for your project. You can use File | New Project from Existing Files wizard (simple way), or set up deployment and web mappings for existing project (a bit more hard way). PhpStorm needs these mappings for debugging (please find details here).
When server and mappings are configured, you set your breakpoints in PHP file(s) and then invoke context menu for a file or folder (in editor or Project view) and choose 'Debug <filename> on <severname>' to start.

Также мне непонятно как отладить к примеру вызов PHP через AJAX.

If breakpoint in the main page is triggered, but in AJAX-called page is not, you have to set xdebug.remote_autostart=1 and xdebug.idekey=PhpStorm options in php.ini, then your PHP run configuration dialog, click 'Wait for Xdebug connection with ide key' radiobutton and enter 'PhpStorm' into the corresponding field. Also please look at the following discussion.

Доходим до конца - в браузере вместо информации - The connection was reset.

It's likely Xdebug crashes the PHP execution (it is a known problem of certain versions of Xdebug). Which Xdebug version do you use?

Regards,
Kirill

0
Comment actions Permalink
Доходим до конца - в браузере вместо информации - The connection was reset.

It's likely Xdebug crashes the PHP execution (it is a known problem of certain versions of Xdebug). Which Xdebug version do you use?

Another possible reason -- script execution time limit has been reached. At least it happens to me in PhpStorm quite often (when I do debuging "slowly" -- entering into plenty of functions etc), but I have never seen anything like that when worked in phpDesigner (same project, running on local server, same php extensions/versions -- on both Apache and IIS 7.5). To bypass this strange behaviour I call "set_time_limit(0);" in the beginning of my index file (only triggers when debug session is detected) -- works perfectly for me every time now.

0
Comment actions Permalink

Hello, Kirill.

XDebug version 2.1.0
Apache/2.2.15 (Win32) PHP/5.2.11

Все даже немного не так обстоит
Браузер отрисовывает страничку затем перерисовывает на "The connection was reset".

Предложение установить set_time_limit(0); тоже не помогло.

Выглядит всё так.
в php файле
<?php
header("Content-type: text/html; charset=utf-8");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<link href="default.css" rel="stylesheet" type="text/css">
<...
далее html код.

При отладке по шагам ближе к концу страничка в браузере отрисовывается.  на последнем шаге браузер ругается.
Если пока страничка на месте кликнуть по ссылке, а в отладчике дошагать до конца - осуществляется переход по ссылке и история начинается сначала.

В какой-то момент мне показалось что страничка остается, если опция "stop session" включена. но дальнейшее это не подтвердило.

0
Comment actions Permalink

Please upgrade to the latest version of xdebug (and maybe PHP as well) and see if the problem persist:

Xdebug 2.1.0
Release date: 2010-06-29
http://xdebug.org/download.php

Браузер (FF) отрисовывает страничку затем перерисовывает на "The connection was reset".

I had similar problem before (quite some time ago, before I start using PhpStorm), but then I did something .. and it's gone (at least I have not seen such behaviour since then). I remember I was updating xdebug to a dev build at some point (2.0.5 or something like that) and that must helped.

0
Comment actions Permalink

Hello, Andriy.

Sorry. its my mistake. i use xdebug 2.1.0.

0
Comment actions Permalink

I see.

In this case I can only suggest to you:
1) Try another browser for a test (I know it sounds very odd, but different browsers may react differently to specific events -- maybe your page has some JavaScript that alters the page (AJAX request, for example) that may trigger another debug session in IDE). I know -- this one is very unlikely, but try it.
2) Install another IDE and debug the same script there (for example: NetBeans, trial version of phpDesigner etc). If everything works fine there and not in PhpStorm, then this most likely is a PhpStorm's bug (just make sure that you are using the same PHP installation, because some of these IDEs come with their own PHP package).

This is just to make sure that problem occurs only when using PhpStorm and that it's not a PHP/XDebug/Apache misconfiguration/issue.


P.S.
I just noticed this:

Выглядит всё так.
в php файле
<?php
header("Content-type: text/html; charset=utf-8");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<link href="default.css" rel="stylesheet" type="text/css">
<...
далее html код.

My question is: do you use output buffering ? I do not remember when and where I saw some article (it was over year ago and this may not be related to your problem at all) in which author complained for some strange behaviour/bugs when debugging such mixed php+html code without output buffering turned on and that it was magically solved for him after including "ob_start();" (in your example it can be inserted before the header() function call).

0

Please sign in to leave a comment.