Using xdebug with PhpStorm

I cannot get my PhpStorm development environment to work with xdebug.

My current setup is this:

  • PhpStorm 2017.1.4
  • MacOS Sierra 10.12.5

Here are the steps I followed.

I have installed php with the following command. I added the postgres parameter because later I need to connect to the PostgreSQL database.

brew install php71 --with-postgresql

      

The next step is to install XDebug with the following command

brew install php71-xdebug

      

So the next step I got from the documentation ( https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html ) is to edit the php.ini file with the following content

[Xdebug]
zend_extension="<path to php_xdebug.dll>"
xdebug.remote_enable=1
xdebug.remote_port="<the port for Xdebug to listen to>" (the default port is 9000)
xdebug.profiler_enable=1
xdebug.profiler_output_dir="<AMP home\tmp>"

      

Just some questions about these fields and XDebug.

  • So my guess is that XDebug is some kind of service that runs on remote_port

    and what PhpStorm uses to write the data? Or do you need to specify the port where the application you want to test is running on?
  • What is a profiler? And can the output directory be whatever I can choose?

So this is my php.ini file, which I think should be:

[xdebug]
zend_extension="/usr/local/Cellar/php71-xdebug/2.5.4/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/usr/tmp"

      

What is this for php.ini. So I have to check the settings in my PhpStorm IDE program. And these are the following:

Settings in PhpStorm 1

Settings in PhpStorm 2

Settings in PhpStorm 3

So this is my setup. In my project I only have one index.php

with <?php echo phpinfo(); ?>

I just click the Chrome icon so it opens directly in the browser to check if XDebug is there. I see the following result.

Phpinfo screenshot

So, I figured yes, let him try debugging. So I changed the file index.php

to the following

$i = 2;
$j = $i + 2;
echo $j

      

I put a breakpoint on the 2nd line. And when I run it, it never stops at a breakpoint. What should I do, or am I mistaken in my configuration somewhere?

+3


source to share


1 answer


To do remote debugging of Xdebug on your page, you need to set a cookie in your browser indicating the server you want to debug the page to, there are many extensions for this, the most famous is the Xdebug helper in Chrome.

I also suggest you follow this tutorial on Debugging Zero Configuration , it's very verbose and clear IMO.



If you still have problems, I will try to help you with pleasure :)

0


source







All Articles