PHP code example of koriym / xdebug-mcp

1. Go to this page and download the library: Download koriym/xdebug-mcp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

koriym / xdebug-mcp example snippets

text
"Debug script.php and find why $user is null at line 42"
"Profile api.php and find the performance bottleneck"
"Trace the authentication flow in login.php"
"Check test coverage for UserService"
text
"script.phpをデバッグして、42行目で$userがnullになる原因を調べて"
"api.phpのパフォーマンスボトルネックを見つけて"
"login.phpの認証フローをトレースして"
"UserServiceのテストカバレッジを確認して"
text
/plugin marketplace add koriym/xdebug-mcp
/plugin install xdebug@xdebug-mcp
json
{
  "$schema": "https://koriym.github.io/xdebug-mcp/schemas/xstep.json",
  "breaks": [
    {
      "location": {"file": "demo/buggy.php", "line": 22},
      "variables": {"$user": "NULL", "$id": "42"}
    }
  ],
  "trace": { "...": "..." }
}
json
{
  "mcpServers": {
    "xdebug": {
      "command": "php",
      "args": ["/ABSOLUTE/PATH/TO/xdebug-mcp"]
    }
  }
}
bash
xrepl --break="script.php:42" -- php script.php
bash
xstep --break="/app/script.php:42" -- \
  docker compose run --rm php php /app/script.php

xtrace -- docker compose run --rm php php /app/script.php
bash
# Debug PHP 7.2 code
xtrace -- /opt/homebrew/opt/[email protected]/bin/php legacy_app.php
xprofile -- /opt/homebrew/opt/[email protected]/bin/php legacy_app.php
xstep --break="legacy_app.php:30" -- /opt/homebrew/opt/[email protected]/bin/php legacy_app.php