Xdebug not connecting MAMP

The Problem:

I've tried for months to get xdebug working with no success. I have spent 10 to 12 hours reading the Jet Brains tutorials, watching YouTube videos, reading blogs, reading the posts in this community, configuring, and re-configuring Intellij and my dev environment. I still have yet to get Intellij to acknowledge a zero-config debugging session initiated from my browser. I get the same results when running a PHP Remote Debug configuration--it just sits and waits but never connects when initiating a session from the browser.

I'm ready to give up. This is my last hope. Here is my configuration info. Please let me know if I have left out any important information:

I'm developing on a Mac, Mojave (10.14.4). My dev server is MAMP Pro. My projects are set up to run with their own domain names on MAMP (the one I will use for demo is http://frontdoor). I've never had trouble using MAMP, however I've considered that it could be part of the problem, I'm just not sure how.

I've been through the tutorials multiple times and I believe I have everything configured correctly, but it's still not working so I must be missing something, somewhere. Here are screen shots of my Intellij configs and php.ini file(s). I know that MAMP has an ini for the server and the command line so I make sure they are identical.

 

This is the xdebug section of the php.ini. I have disabled opcache so there are no conflicts. Not sure if there is anything else I should say about my php.ini file.

Below is the xdebug section from a phpinfo() page.

 

I've installed the Firefox and Chrome browser extensions and tried both with the same results. Below is a config screen from Firefox. The Chrome config is the same.

 

Here is the PHP configuration with paths and xdebug version in Intellij.

 

This is the debugger validation screen in Intellij. It passes and Intellij knows where everything is.

 

NOTES:

When I click on the listener icon (the debug phone) and then start the browser for a zero-config debug session nothing happens. I mean not even an entry in the xdebug log. In fact, I never get anything in the xdebug log.

The Intellij/PHPStorm instructions page for Zero-Config indicates that an "Incoming Connection From Xdebug" window becomes available. I've never seen that, nor can I find it in any menu or set up option so that's where my zero-config experience ends every time.

When I try to use the Run/Debug Configuration it just waits for a connection but never acknowledges the browser attempts to connect (see below).

 

This is my Run/Debug Configuration for this app.

 

The most frustrating thing about using the Run/Debug Configuration is, it deactivates any break points I set and displays the following message when I hover over the former break point.

 

I cant figure out how the index file could not be in the path, or how the path could not be mapped. I've searched Intellij settings and PHP configurations and have set every path and mapping variable related to this application. I've checked my MAMP server settings to make sure I havent missed something (there doesn't seem to be anything wrong with the MAMP settings. The application runs correctly without any issues--one of the reasons why I chose this app for the test).

The last thing I tried is debugging a single page in a completely different directory. I got the same non-response. Intellij just kept waiting for a connection even though the browser plugin was active and the page was being refreshed.

So, here I am frustrated and feeling like xdebug is a complete waste of time. I know it will be worth my effort if I can get it working. Others seem to have been successful installing it. Please help me figure this out. I'm hoping someone can find something I've missed.

Thanks

4 comments

Hi there,

Xdebug has to write into xdebug log. If it does not write .. then it either does not see the "debug me" flag (which is not your case as you have autostart) or it cannot write to that file. Don't know what else it might be. On Linux it could be stuff like SELinux that may prevent Apache from making outgoing connections. In your Mac case -- no ideas.

Right now it's possible that xdebug simply does not even try to connect to IDE (for whatever reason). Does putting "xdebug_break();" in your code makes any difference?

try installing different PHP and different xdebug and try to debug via CLI interface (as you can pass all params via command line).

0

I support Andriy on checking if the xdebug.log file has the correct permissions.

  1. The file should already exist.
  2. It makes sense to give it 777 just for the sake of testing.

Please check our guide on this topic: https://intellij-support.jetbrains.com/hc/en-us/articles/206544819-How-to-collect-remote-log-for-XDebug

Also, what is frontdoor? Is it a virtual host, or it's just another name of your Mac? When Listening for PHP Debug Connections is on, does nc -z frontdoor 9009 give you any output? If it doesn't, it's better to change the xdebug.remote_host php.ini parameter to 127.0.0.1 instead of frontdoor.

Now, to the mappings. Are you opening the project in PhpStorm directly from /Applications/MAMP/htdocs/frontdoor? You can check that in the Project tool window (Cmd + 1) in the top.

If you do, you need no mappings. If you don't, PhpStorm should know how files from MAMP relate to your project, you can set this up at Preferences | Languages & Frameworks | PHP | Servers.

But first please make sure PhpStorm receives connection from Xdebug, it's the most important thing now. When it happens, PhpStorm will try to guess the mappings if there's no server added yet, most probably it'll be a correct guess.

P.S. Please read IntelliJ IDEA where I wrote PhpStorm.

0

Thanks for the responses. I will try your suggestions and update when I have results.

0

Re. xdebug.log:

There has never been an xdebug.log file in the directory specified in the settings (set the path in php.ini, xdebug.remote.log when following the tutorials). I was concerned about that a few days ago so I created one. It has permissions set to 777.

frontdoor is a virtual host. I have a lot of projects set up in the MAMP htdocs directory, each with their own virtual host domain. Intellij and xdebug are using the code directly from MAMP/htdocs/frontdoor directory.

Path Mappings and xdebug_break():

I checked the server configuration and found the 'Use Path Mappings' box was checked. I unchecked it and that actually made a difference.

The first test I did after your responses was adding xdebug_break(); to the index file. I had no response... that is, until I unchecked the 'Use Path Mappings' box. After that my xdebug log file blew up with tons of data!

I'm still having issues with getting xdebug to run and break without inserting xdebug_break() but, this is very encouraging. I have made progress and seen an actual connection between the browser plugin and Intellij for the first time.

New Error

My current issue is figuring out how to fix the following error. It shows up in the IDE event log when I step past the xdebug_break() line.

Cannot accept external Xdebug connection: Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])'

Thanks for your help and suggestions. I will update more as things improve and if anyone has seen this error I would appreciate any insight you might have.

 

0

Please sign in to leave a comment.