Need Help Setting Up Browser XDebug

HI - I'm totally new to PHPStorm, but so far I love what I see.

I have managed to get XDebug loaded into my ini file. I have tested Xdebug using very simple scripts from within PHPStorms debugger and so far it appears to work - ie I can step through and see the variables come up.

Now I want to iniate the debugger from a bowser - I have added the Xdebug extension to Chrome as well as FF. I have followed the user guide, turned on the listen for connections.

I am using Storm alone, and have my script siting under Apache in htdocs ie not using the internal web server.

Here is where things go wrong:

- when going back to the browser and reloading the script  through localhost/phpstormtest/hello.php I get the following :


xdebug.PNG

Here is the code which created it:

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="default.css">
       </head>
    <body>
    <div id="test">

    <?php

    $a=7;
    $b=10;
    $c=42;
    $y = 'yes';
    $n = 'nay';

    ?>
    <table>
    <tr>
    <td < width="300">Results</td>
    <td>
    <?php
        if($a+$x==$c){
        echo "<br>" .$y ." !";
        }
        else echo $n . " you fail";


    ?>

    </td>
    </tr>
    </table>
    </div>
    </body>
    </html>


So I am kind of stuck --- if anyone can guide me towards success or give advice as to what I am doing wrong - I off them my heart felt thanks !

0

What kind of help do you need?

If regarding the error on screenshot: your PHP is setup for development mode and catches as many errors as possible -- check error_reporting setting in your php.ini if you want to relax such reporting (which I do not recommend to do -- better find and avoid such simple errors in advance).

You clearly have an error in your PHP code and xdebug clearly states where it is -- undefined variable $x line 28

if($a+$x==$c){

I guess you meant to write $b instead of $x.

Regarding debugging -- if you have managed to setup webserver, php & configured xdebug (you said it's working in simple script -- as I understand it works in PhpStorm), then you are doing well -- from yor description I see nothig that can tell what kind of debugging/setting up issues you are having.

0

@Andriy - Thank you for your response. The help I need is in figuring out what is wrong with my configuration. The error was intentionally put there to test the debugger.

  1. First of all, even if I turn off the "listener", I can not run my php page anymore without getting this report as per the attached image.
  2. Even if I take the error out of the script I still get the report as per the attached image.
  3. The bookmark, "start debugger" has no effect on the behaviour of the browser or the debugger.


My expectattions are to be able to run my code in a browser and have it execute without any Storm messages coming up ( provided there are no errors )

If I turn on "Listening"  then I expect the browser to respond to the bookmark.

Many Thanks

0

1. In case you have not seen this yet -- here are few articles about debugging, configuring xdebug and using bookmarks: http://confluence.jetbrains.net/display/WI/Documentation (basically, #4 and #6)

2. You really should provide your xdebug configuration (actual settings in php.ini + output of phpinfo() ) as well as PhpStorm one (those that related to debugging: Settings | PHP | Debug, Settings | PHP | Servers)

3. If you are using firewall, make sure that PhpStorm can accept incoming connections (it is xdebug who makes connection to the client, which is PhpStorm)

Even if I take the error out of the script I still get the report as per the attached image.

That's cannot be -- then it must be another error elsewhere (or page was cached by browser). If you are saying that you have fully valid code, then I do not see how xdebug can show the same error message.

First of all, even if I turn off the "listener", I can not run my php page anymore without getting this report as per the attached image.

I would suggest actually starting with very basic script without any html/php mix and it has to be very basic and simple, something like this:

<?php
$a = 10;
$b = 7;
$c = $a + $b;
echo "Result: " . $c;

If you put breakpoint at 2nd line, you should be able to go trough whole file line by line (no jumps between lines on if and other conditional instructions -- as simple as possible)..

My expectattions are to be able to run my code in a browser and have it execute without any Storm messages coming up ( provided there are no errors )

What kind of messages do you see coming up from PhpStorm?

From PhpStorm side you should see only 1 dialog window on first successful debug session initiation -- to map source files (in case website root differs from project location). Any other debug sessions should be without any additional "messages" (unless there are some problems). In any case -- please try deleting entry in "Settings | PHP | Servers" -- maybe (although unlikely) it was setup incorrectly.

If I turn on "Listening"  then I expect the browser to respond to the bookmark.

I do not see how browser should "respond to bookmark" here. The algorithm (in general) is like this:

  • You start listening in PhpStorm
  • Navigate to the page you want to debug (or to the page that is a click away from it)
  • Activate "Start debug session" bookmarklet -- this will only set the xdebug cookie for next request, nothing more
  • Navigate to the page in question (if already there -- refresh the page or whatever)
  • If everything is fine and PhpStorm accepts debug session then it should inform you about this (e.g. taskbar icon will flash few times or whatever it may be on your OS).
0

请先登录再写评论。