Skip to content

Instantly share code, notes, and snippets.

@ggMartinez
Last active June 21, 2024 07:28
Show Gist options
  • Save ggMartinez/e871d07825585a5e1593d9e8cde8b79c to your computer and use it in GitHub Desktop.
Save ggMartinez/e871d07825585a5e1593d9e8cde8b79c to your computer and use it in GitHub Desktop.
XDebug

XDebug

Xdebug es un modulo de debugging de PHP.

Consideraciones

Vamos a instalar XDebug 3.3, en PHP 8.2, con XAMPP.

Si no es lo que tenes, suerte. Por rebelde.

Instalación en Windows

Tengamos en cuenta que se esta usando XAMPP. Si no se usa XAMPP, manejarse. Si sos rebelde, sos groso.

  1. Descargamos el DLL de Xdebug desde acá
  2. Movemos el DLL a C:\xampp\php\ext, y lo renombramos en php_xdebug.dll
  3. Editamos el archivo C:\xampp\php\php.ini, y al final agregamos:
zend_extension = xdebug
[xdebug]
xdebug.mode=develop,debug
xdebug.discover_client_host=1
xdebug.client_port = 9003
xdebug.start_with_request=yes
xdebug.log_level=0
  1. Descargamos la extensión de VS Code PHP Debug. Está en la sección de Extensiones, o en el Marketplace de VS Code.
  2. En el proyecto debemos tener un archivo .vscode/launch.json con el siguiente contenido:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Iniciar XDebug Local",
            "type": "php",
            "request": "launch",
            "port": 9003
        },
        {
            "name": "Iniciar XDebug en Docker",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/app": "${workspaceFolder}"
            }
        }
    ]
}

Alternativamente, podemos configurarlo de forma Global en VSCode, yendo a Settings -> Features -> Debug -> Launch -> Edit in settings.json.

Allí, en el sector "configurations" : [] agregamos el siguiente contenido dentro de []:

{
    "name": "Iniciar XDebug Local",
    "type": "php",
    "request": "launch",
    "port": 9003
},
{
    "name": "Iniciar XDebug en Docker",
    "type": "php",
    "request": "launch",
    "port": 9003,
    "pathMappings": {
       "/app": "${workspaceFolder}"
    }
}
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003
xdebug.client_host = "127.0.0.1"
xdebug.idekey = VSCODE
xdebug.log_level=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment