Step Debugging from an Editor

Step debugging pauses PHP on a line so you can read every variable and continue line by line. The editor listens on port 9003; Xdebug 16,266 connects out to it when a script starts and then takes DBGp commands. In VS Code 550 , install PHP Debug (xdebug.php-debug); PhpStorm 856 has it built in.

.vscode/launch.json: listen, and map server paths to the workspaceJSON
{
  "version": "0.2.0",
  "configurations": [{ "name": "Listen for Xdebug", "type": "php", "request": "launch",
    "port": 9003, "pathMappings": { "/app": "${workspaceFolder}" } }]
}

pathMappings matters when code runs in a VM or container. To show what the editor sends, dbgp.php, a 23-line script listening on 9003, sends each argument as a command and prints the XML replies without namespaces:

A breakpoint on Cart.php line 17, driven by a scripted clientShell
php dbgp.php 'breakpoint_set -t line -f file:///app/src/Cart.php -n 17' 'run' \
  'property_get -n $sku' 'property_get -n $total' 'stack_get' 'step_over' \
  'eval -- $total' 'detach' &
php -d zend_extension=xdebug -d xdebug.mode=debug -d xdebug.start_with_request=yes checkout.php
Output
...
-> property_get -i 3 -n $sku
<- <response command="property_get" transaction_id="3">
   <property name="$sku" fullname="$sku" type="string" size="9"
     encoding="base64"><![CDATA[QkstU1FMLTAx]]></property></response>
...
-> eval -i 7 -- JHRvdGFs
<- <response command="eval" transaction_id="7">
   <property type="int"><![CDATA[4450]]></property></response>
...

Each editor panel is a command: Variables is property_get (QkstU1FMLTAx is base64 for BK-SQL-01), Call Stack is stack_get, F10 is step_over, the Debug Console is eval. At the break $total was 0; one step later, 4450.