I had to spend some time to get my PhpStorm working with debugging a Magento 2 store we are developing. This is a short notice of what I found out and how I got it working.

A couple of weeks ago I had a working setup where I could debug both command line commands and pages using PhpStorm. Last weeks I have been developing a command line but swapped back to some page coding now and it did not work. In my initial setup I mainly followed this setup but since I use MAMP(none PRO) this article was helpful.

After a bit of struggling I found out the reason why it was not working any longer. Because of some mysterious reason I had checked the “Use path mappings…” check box. DON’T!

And as you see above it works just fine with using localhost in the servers configuration.

Another useful things to solve this was to add xdebug.remote_log="/tmp/xdebug.log" to the two php.ini files and restart MAMP and then look at the log with tail -f /tmp/xdebug.log. I noticed I had a couple of lines like this:
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)

The lines starting with W(guess meaning Warning) should not be there. It means the connection was not completely successful even though reading the line indicates some sort of success but there is the error too.

And while we are at it. I have not yet figured out the meaning of this button.

There seems to be no need to listen for PHP debug connections using this setup.