1

Imagine I have a test.html file which contains a jQuery line which calls a test.php file like in the example below:

<html>
    <head>
        <title>Debug test</title>
        <script src="jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(document).ready( function()
            {
                jQuery('#testdiv').load('test.php' );
            });
        </script>
    </head>

    <body>
        <div id="testdiv">
        </div>
    </body>
</html>

Now imagine the php file test.php returns a result like in the example below:

<?php
test();

function test()
{
    echo "Ok called me!";
}
?>

The two files of course run under a server like Apache.

What I'd like to accomplish would be something like in NetBeans Java EE debug: put a debug breakpoint in test.php fun() function and one in the jquery call inside test.html, then call localhost/test.html and see the first breakpoint inside jquery call being hit and then the second breakpoint inside test.php being hit.

How can I obtain (if possible) this using jetBrains Intellidea WebStorm and PHPStorm? Thank you

9
  • 1
    FYI: WebStorm does NOT support PHP debugging. Commented Aug 22, 2013 at 15:44
  • I mentioned Intellidea WebStorm and PHPStorm as a combination to make this possible, not one or the other alone. Still wondering whether it is somehow possible to debug php and js together anyway. Commented Aug 22, 2013 at 15:47
  • Yes, you can -- in PhpStorm (no need for two IDEs running at the same time). PHP Debugger (Xdebug) should be configured to start debugging automatically + Zero-Configuration approach should be used (phone handle icon on main toolbar) -- confluence.jetbrains.com/display/PhpStorm/… Commented Aug 22, 2013 at 15:58
  • The idea is: 1) activate PHP debugger in PhpStorm (phone handle icon); 2) Launch JavaScript debug to debug your JS code. When request will be made to a PHP file, xdebug will contact PhpStorm to debug PHP code. When PHP debug portion will be finished, you should be able to continue debugging your JS code. P.S. This assumes that you already configured IDE and able to debug PHP and JS separately. Commented Aug 22, 2013 at 16:02
  • I am able to debug test.html and test.php separately, XDEBUG is correctly activated however when I open localhost/test.html no incoming debug call is received. From the guide confluence.jetbrains.com/display/PhpStorm/… I cannot understand the part "Set initial path mappings", can you tell me where to find that menu? Commented Aug 22, 2013 at 16:18

1 Answer 1

2

Solution:

As LazyOne suggested I should use "zero configuration" option inside PhpStorm, complete instructions at jetbrains/...

Below is a description of the steps:

  1. Install Xdebug (sudo apt-get install php5-xdebug)
  2. Add inside /etc/php5/apache2/php.ini the lines:

    [Xdebug]
    zend_extension=/usr/lib/php5/20100525+lfs/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_host=localhost
    xdebug.remote_port=9000

  3. restart apache: "service apache2 restart"

  4. check Xdebug is enabled "php --version" should show "with xDebug vx.x"
  5. Toggle the “Listen debugger connections” button.listen debug connections, this will listen for incoming connections to the test.php script
  6. Set a breakpoint in the test.php source code
  7. Activate the xdebug debugger, to do this we need to set a special GET/POST or COOKIE parameter. You can do it manually, but it is much more convenient to use a special online tool bookmerklets generator

    enter image description here

  8. Open localhost/test.php and you will see a request to start debugging at line of test.php.

Sign up to request clarification or add additional context in comments.

1 Comment

You may want to use this also, dude :) chrome.google.com/webstore/detail/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.