Aller au contenu
Cheat Sheet
Visual Studio Code

[PHP] Utiliser Xdebug dans VS Code

Voici comment configurer Xdebug dans Visual Studio Code.

  • Installer l’extension “PHP Debug” dans VS Code.
  • Dans la configuration de VS Code (fichier settings.json), ajouter le chemin vers l’exécutable PHP dans la variable php.validate.executablePath.
    Exemple :
{
    "git.autofetch": true,
    "php.validate.executablePath": "C:\\php\\php-7.2.7\\php.exe"
}
  • Récupérer le contenu du phpinfo() et le coller dans le Wizard de Xdebug. Cela donnera le bon fichier à télécharger.
  • Télécharger le fichier dans le répertoire des extensions PHP (exemple : C:\php\ext\php_xdebug-2.9.0-7.2-vc15.dll).
  • S’assurer qu’il y a bien un fichier php.ini dans le même répertoire que php.exe.
  • Editer le fichier php.ini et s’assurer qu’il y a une section “Xdebug” :
[xdebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host=localhost
xdebug.remote_port=9000
  • Préciser dans php.ini le chemin de l’extension :
zend_extension = C:/PHP/ext/php_xdebug-2.9.0-7.2-vc15.dll
  • Dans VS Code, créer une configuration de debug Xdebug, qui précisera le bon port de communication (ici, 9000) :
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}
  • Dans VS Code, lancer un terminal et lancer un serveur PHP sur le dossier courant :
C:\php\php-7.2.7\php.exe -S localhost:8000

pour lancer un serveur sur un autre dossier :

C:\php\php-7.2.7\php.exe -S localhost:8000 -t C:/Mon/Repertoire/www/
  • Dans un navigateur, appeler la page avec le paramètre ?XDEBUG_SESSION_START :
http://localhost:8000/index.php?XDEBUG_SESSION_START

Il sera alors possible de faire du pas à pas, de consulter le contenu des variables, etc…

Créer un VirtualEnv pour Python
[Selenium] utiliser une instance de navigateur existante
php visual studio code vscode xdebug

Catégories

  • Android
  • Calibre
  • Docker
  • Excel
  • Git
  • Google Sheet
  • Knime
  • Linux
  • Logiciels
  • Matériel
  • Non classé
  • Notepad++
  • Power BI
  • Programmation
  • Python
  • Qlik
  • Service
  • Synology
  • Visual Studio Code
  • Windows
  • Word
  • WordPress

Étiquettes

android apache audio bootloader convertion custom rom dict drivers excel fastboot firefox kobo lambda library lineageos linux manette markdown moto g LTE motorola mp3 nas netsh notepad++ password peregrine php pip python qlik qliksense qlikview realtek rom selenium synology twrp venv virtualenv visual c++ wifi windows wordpress youtube yt-dlp

Tags

android apache audio bootloader convertion custom rom dict drivers excel fastboot firefox kobo lambda library lineageos linux manette markdown moto g LTE motorola mp3 nas netsh notepad++ password peregrine php pip python qlik qliksense qlikview realtek rom selenium synology twrp venv virtualenv visual c++ wifi windows wordpress youtube yt-dlp
Thème par Colorlib Propulsé par WordPress