Default version > 7.0.31
Languages > PHP > Extensions > Xdebug (Debugger) > Check
Check settings:
File > Edit Template > PHP > 7.0.31
> OK
[xdebug]
MAMP_Xdebug_MAMPzend_extension="/Applications/MAMP/bin/php/php7.0.31/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
;xdebug.profiler_enable=0
;xdebug.profiler_output_dir="/Applications/MAMP/tmp"
Xdebug provides an interface for debugger clients that interact with running PHP scripts.
http://www.vaerenbergh.com/blog/xdebug-and-sublime-text
Sublime knows when to listen to your browser when a certain cookie is set. For sublime this cookie is "XDEBUG_SESSION = sublime.xdebug". To avoid setting this cookie by hand, we can add a helper addon in our browser so we can enable and disable Xdebug whenever we want.
- Install Chrome Xdebug helper
- Right click on the bug icon and select Options
- In IDE key select Other and enter
XDEBUG_SESSION = sublime.xdebug
- Left click on the bug icon and select Debug (green)
Configure the path mapping:
Configuration The following settings can be configured in Xdebug.sublime-settings or in *.sublime-project files:
Features Remote debugging by configuring path mapping
path_mapping For remote debugging to resolve the file locations it is required to configure the path mapping with the server path as key and local path as value.
- SublimeText > Preferences > Package Settings > Xdebug > Settings - User
- Add a path mapping:
::1
is taken from MAMP Pro > Tools > show /etc/hosts File
{
// Example:
// "/absolute/path/to/file/on/server" : "/path/to/file/on/computer",
// "/var/www/htdocs/example/" : "C:/git/websites/example/"
"path_mapping": {
"::1" : "/Volumes/DanBackup/Websites/www.dontbelievethehype.co.nz/"
}
}
Run the Xdebug debugger in Sublime:
- Open Sublime
- Install the Xdebug Client (SublimeTextXdebug)
- Tools > Xdebug > Start Debugging
Load the local website www.dontbelievethehype.co.nz
in Chrome
An error generating file automatically opens in Sublime with line 30 highlighted with a green arrow.
I expect to see a stack trace in Sublime, but there's nothing.
However when I open /Volumes/DanBackup/Websites/www.dontbelievethehype.co.nz/wp-content/debug.log
the stack trace is there, with an error for line 30.
Disabling WP_DEBUG_LOG
(preventing output to debug.log
) doesn't prevent Sublime from auto opening the file:
// outputs errors to ./debug.log
define('WP_DEBUG', true);
if ( WP_DEBUG ) {
define('WP_DEBUG_LOG', false);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
}
Disabling the Query Monitor caused the following to be respected (because the output wasn't being redirected to the plugin):
// wp-config.php
define('WP_DEBUG_DISPLAY', true);
https://www.bluestatic.org/software/macgdbp/
A Cocoa/Mac OS X debugging client for PHP using the Xdebug protocol
As suggested in the MAMP Pro interface next to the XDebug checkbox.
Works first time if there is no XDebug session running in Sublime Text, else shows socket error.
However, MacGDBp raises different errors from Sublime Text debug.log
.
The naming is somewhat similar to the XDebug option:
xdebug.remote_handler Type: string, Default value: dbgp Can be either 'php3' which selects the old PHP 3 style debugger output, 'gdb' which enables the GDB like debugger interface or 'dbgp' - the debugger protocol. The DBGp protocol is the only supported protocol.
Note: Xdebug 2.1 and later only support 'dbgp' as protocol.
xdebug.remote_connect_back=1
and
https://stackoverflow.com/questions/1868568/xdebug-configuration-with-php-fastcgi-and-eclipse
and outputting an XDebug log:
Log opened at 2018-11-09 20:52:53
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).
E: Could not connect to client. :-(
Log closed at 2018-11-09 20:52:53
and watching http://schurpf.com/xdebug-phpstorm-mamp/
In my case, the
poll success, but error
was due to how my IDE was not properly configured to successfully connect to Xdebug on the server, which was alsolocalhost
. It turned out that I had earlier changed theremote_port
setting in the INI and forgot the restart to web server. However, even more important was to make sure PHPStorm, my IDE, had a Languages and Frameworks -> PHP -> Server config for thelocalhost
site with Use path mappings unchecked.Also, I had to disable
remote_connect_back
, as this discussion explains.