Cannot Get xdebug working with MAMP on Mac

So been at this for a bit and thought someone here might be able to help me.

So I am using a MAMP stack on mac. I think I have the PHP interpreter sorted out well:

Screen Shot 2015-10-17 at 6.09.13 PM.png

So that is the link to my php executable and I changed my php.ini to:

Screen Shot 2015-10-17 at 6.17.34 PM.png

And everything seems pretty good thus the 'Debugger: Xdebug 2.2.7' in the first pic.

I also downloaded the chrome jetbrains plugin so when I go to debug Chrome gets launched:

Screen Shot 2015-10-17 at 6.10.16 PM.png

When I try to debug

Screen Shot 2015-10-17 at 6.10.31 PM.png

I have no idea why it is skipping the breakpoint but I have never debugged with phpstorm or php for that matter
(usually just use print_r, var_dump... but I really would like to get this working).

I did the Web Server Debug Validation and I ended up with:

Screen Shot 2015-10-17 at 6.08.37 PM.png

This looks like it should be at least to me.

In the debugging window it looks like:

Screen Shot 2015-10-17 at 6.10.44 PM.png

But no variables are listed and the stack is empty.

I'm not sure what I am missing it seems like something simple since phpstorm is screaming at me some errors.

Can anyone help?

11 comments
Comment actions Permalink

Hi there,

I'm not sure what I am missing it seems like something simple since phpstorm is screaming at me some errors.

Based on your screenshots you have launched JavaScript debug instead of PHP. Plus, you do not need jetBrains Chrome extension for PHP debug -- only for JS and LiveEdit.

I suggest deleting your invalid Run/Debug Configuration ("Run | Edit Configuraions..." or via drop-down box on main toolbar mext to Run/Debug buttons) and trying again.

0
Comment actions Permalink

You are 100% right!

I am watching the video and going through the links you posted since I am new to phpstorm, php debugging and php!

Thanks!

0
Comment actions Permalink

Trying the web application option now trying to firgure out:

Screen Shot 2015-10-17 at 7.47.59 PM.png

I'm thinking I am missing something in my php.ini or there is a mistake there?

0
Comment actions Permalink

Possibly.

You are on Mac using MAMP. Most likely it has 2 different php.ini files -- one for CLI (which you have edited already) and one for web server (Apache). Since you are debugging a web page your PHP may use different php.ini in this case.

To verify that -- create some test.php file with <?php phpinfo(); as a content and execute it in a browser. Then check for config file that was used there (it's in the header; you can also verify your xdebug section there) and edit it accordingly.

P.S.
Do not forget to restart Apache after making changes in php.ini

0
Comment actions Permalink

To see if debug works at all -- try CLI debug first.

For that -- create simple php file and place few simple instructions there, 1 per line (something like $a =1; $b = 2; $c = $a + $b; echo $c;) Then create Run/DEbug config of "PHP Script" type and try to debug it.

0
Comment actions Permalink

Hey thanks man I already did what you posted above because I did exactly what you thought (edited the cli php install php.ini file).

So I am indeed editing the right php.ini file and ?XDEBUG_SESSION_START=11851 is getting attached to my url when browser launches
and it looks like phpstorm wants the # portion sent back to it as some kind of handshake and it isn't happening.

So I am just messing around trying to figure out what is up. The video you linked was really good btw and I was envious when everything
just worked! Might be something with MAMP or Mac but it is pretty frustrating as it doesn't seem that complex.

Once again thanks for your assistance.

0
Comment actions Permalink

Got it working think it was not configuring apache under deploy now I have it working.
BB in like a few dogs need a walk but gonna check out other debugging options as well.

Thanks again!

0
Comment actions Permalink

Not sure if this is working as it should but I have this set:
Screen Shot 2015-10-17 at 9.33.09 PM.png

And then when I hit the debug icon (the bug) it seems to debug and I get this string:

/Applications/MAMP/bin/php/php5.6.10/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9001 -dxdebug.remote_host=127.0.0.1 /Applications/MAMP/htdocs/project

And then everything seems to work but it doesn't seem like I am using PHP Web Application or PHP Built-in Web Server as is suggested in
the official tutorials...

Is setting this up non-intuitive or is this just me?

0
Comment actions Permalink
And then everything seems to work but it doesn't seem like I am using PHP Web Application or PHP Built-in Web Server as is suggested in the official tutorials...

Yes -- this is a CLI debug -- it does not use web server of any kind.

So .. did you managed to make it work via browser or not?

If not -- I need more info:
1) Full path to the file you are trying to debug
2) What is the path to that file as seen by MAMP/Apache
3) Are there any symlinks in that path?
4) Please provide xdebug log for such unsuccessful debug session: http://xdebug.org/docs/all_settings#remote_log
5) Please also provide xdebug section of the phpinfo() output captured via browser

Right now I think that it could be because of symbolic link somewhere in the path (really depends on your setup: where you keep your actual projec and from where Apache serves them). You have to remember that xdebug only works with final/resolved paths while PHP/PhpStorm works with paths as is. If that's the case then you will either have to provide the path mappings for this project (Preferences | Languages & Frameworks | PHP | Servers) or you will have to serve the project from non-symlinked location (e.g. "/Projects/mysite.com")

0
Comment actions Permalink

So I got the zero config debugging working by clicking the "Listening for PHP debugging Connections" then using the browser icon in code
window.

I got PHP Remote debug working by putting xdebug.idekey = PHPSTORM into my php.ini and then putting PHPSTORM in remote server config.

I got PHP Web Application Debugging working by using the bookmarklet "Debug this page" which must send ide key back to phpstorm and debugger works.

I got the PHP built in debugger working too when launched from browser icon in code section of phpstorm.

I think my main issue was not not setting my 'Webserver root url' properly
Screen Shot 2015-10-18 at 8.36.09 AM.png

I really do appreciate your help. I just know the importance of debugging and wanted to learn this
upfront so I would not start getting in the bad habit of relying on print statements and the like.

I do think this processes could be a bit more straighforward than as it is but maybe its just me.

Luckily there are people like you that help.

Cheers again Andriy!

0

Please sign in to leave a comment.