Overview
Sometimes there is a case we spending more time on command line rather than on browser when developing a PHP application. It is true especially when we are in unit testing phase. Usually Xdebug remote debugging activated by sending XDEBUG_SESSION_START=session_key
in query string or http post body. For debugging from command line we need to set environment variable XDEBUG_CONFIG="idkey=session_key"
.
Debugging with Sublime and Xdebug
Default Xdebug session name for Sublime Xdebug Client is "sublime.xdebug". Assuming all the configuration related with Xdebug and Sublime are done, here is the way to begin debugging from command line.
- Start Xdebug on Sublime by going to Tools » Xdebug » Start Debugging
- Set your break point somewhere in your code
- Run your PHP script on command line, here I'm using phpunit.
$ XDEBUG_CONFIG="idkey=sublime.xdebug" phpunit app/tests/notifier/v1/UserLoginNotifierQueueTest.php
- Go back to Sublime and all the debugging window are presented, the execution still paused at the break point.
- We can start to examine variables or doing "Step-In/Out".
0 comments:
Post a Comment