Local command line debugging with XDebug and PHPStorm, MAMP Pro, OS X

Earlier I had MAMP v2.x working fine with XDebug. It was configured so that I could turn it on and off for every browser connection using the following JavaScript bookmarks:

javascript:(/**%20@version%200.5.2%20*/function()%20{document.cookie='XDEBUG_SESSION='+'PHPSTORM'+';path=/;';})()

javascript:(/**%20@version%200.5.2%20*/function()%20{document.cookie='XDEBUG_SESSION='+''+';expires=Mon,%2005%20Jul%202000%2000:00:00%20GMT;path=/;';})()

      

I could also debug scripts executed on the command line with bash turning debugging on and off with:

export XDEBUG_CONFIG="idekey=PHPSTORM"
unset XDEBUG_CONFIG

      

I have upgraded to MAMP Pro 3.x and am debugging from the browser and can turn it on and off using JS bookmarks. However, I was unable to get the debugs to work with the terminal. The default installation for MAMP is for XDebug to autorun. I don't want this as it prevents other sites on the server from being accessed while debugging, so I changed the configuration. Here's what I have:

[xdebug]
 MAMP_Xdebug_MAMP
 xdebug.remote_enable=on
 xdebug.remote_log="/var/log/xdebug.log"
 xdebug.remote_host=localhost
 xdebug.remote_handler=dbgp
 xdebug.remote_mode=req
 xdebug.remote_port=9000
 xdebug.idekey="PHPSTORM"

      

So in order for my script to use the correct php file, I linked sym / usr / bin / php to / Applications / MAMP / bin / php / php 5.4.30 / bin / php

I also tried including xdebug.remote_autostart to see if I could debug the terminal. Not.

There is a lot of information online on how to debug remote command line, but I haven't found anything that helps with local command line debugging.

I am looking for ideas on how I can get local command line debugging working with MAMP Pro 3.x.

SOLUTION UPDATE: I ran the script with phpinfo () from the cli and saw that for some reason when calling php from the command line, it loads a different php.ini. I added the following to / Applications / MAMP / bin / php / php 5.4.30 / conf / php.ini and now it works!

zend_extension="/Applications/MAMP/bin/php/php5.4.30/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.idekey="PHPSTORM"

      

Thanks to @Niloct for prompting the idea that led me to a solution, although I'm ashamed I didn't think about it at first.: /

+3


source to share


1 answer


In the PHP installation directory, make sure the config xdebug.ini

is in the directory conf.d

, so the cli and webserver will activate xdebug:

MacBook:5.5 teixeira$ pwd
/usr/local/etc/php/5.5

MacBook:5.5 teixeira$ ls
conf.d               php-fpm.conf         php.ini
pear.conf            php-fpm.conf.default

MacBook:5.5 teixeira$ ack -i xdebug
conf.d/ext-xdebug.ini
1:[xdebug]
2:zend_extension="/usr/local/Cellar/php55-xdebug/2.2.4/xdebug.so"
3:xdebug.remote_enable = 1
4:xdebug.remote_host = 127.0.0.1
5:xdebug.remote_port = 9005
6:xdebug.remote_handler = dbgp
7:xdebug.profiler_enable=0
8:xdebug.profiler_enable_trigger=1
9:xdebug.idekey=PHPSTORM
10:xdebug.remote_log="/tmp/xdebug.log"

      



then release php -i | grep xdebug

to check if it's loaded in the CLI.

ALSO, triple port check, please note that I am using 9005

because of a conflict I had with php-fpm

.

+1


source







All Articles