Reputation: 1420
Previously I had MAMP v2.x working great with XDebug. It was configured so I could toggle it on and off for each browser connection using the following bookmarked JavaScript:
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've upgraded to MAMP Pro 3.x and have debugging working from a browser and can turn it on and off with the JS bookmarks. However, I've been unable to get debugging to work from terminal. The default install for MAMP is for XDebug to autostart. I do not want that since it prevents access to other sites on the server during debugging so I've modified the config. 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 that my script uses the correct php binary I've sym linked /usr/bin/php to /Applications/MAMP/bin/php/php5.4.30/bin/php
I've also tried turning xdebug.remote_autostart back on to see if I could get debugging from terminal working. No go.
The web has lots of info on how to do remote command line debugging but I've found nothing that helps on local command line debugging.
I'm looking for ideas on how I can get local command line debugging working with MAMP Pro 3.x.
SOLUTION UPDATE: I ran a script with phpinfo() from 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/php5.4.30/conf/php.ini and it now 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 sparking the idea that led me to the solution though I am ashamed I did not think of it at first. :/
Upvotes: 4
Views: 2727
Reputation: 10015
In PHP setup directory, be sure the configuration xdebug.ini
is in conf.d
directory so cli and webserver get xdebug activated:
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 issue php -i | grep xdebug
to check if it's loaded in CLI.
ALSO, triple check the port, notice that I'm using 9005
because of conflict I had with php-fpm
.
Upvotes: 1