简体   繁体   中英

WebStorm and PHPStorm debug php and js at same time

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

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. 侦听调试连接 , 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

    在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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