Skip to content

Instantly share code, notes, and snippets.

@matyo91
Created September 5, 2013 11:49
Show Gist options
  • Select an option

  • Save matyo91/6449115 to your computer and use it in GitHub Desktop.

Select an option

Save matyo91/6449115 to your computer and use it in GitHub Desktop.

Revisions

  1. matyo91 created this gist Sep 5, 2013.
    82 changes: 82 additions & 0 deletions Configuration - Debugger du PHP avec PhpStorm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,82 @@
    # Installation l'environnement de debug sur Ubuntu

    Nous allons installer et configurer Xdebug sur le serveur

    # install xdebug
    $ sudo apt-get install php5-xdebug

    # configure xdebug
    $ sudo nano /etc/php5/apache2/php.ini

    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;


    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ; extension=modulename.extension
    ;
    ; For example, on Windows:
    ;
    ; extension=msql.dll
    ;
    ; ... or under UNIX:
    ;
    ; extension=msql.so
    ;
    ; ... or with a path:
    ;
    ; extension=/path/to/extension/msql.so
    ;
    ; If you only provide the name of the extension, PHP will look for it in its
    ; default extension directory.

    zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so
    xdebug.idekey = by_lamp
    xdebug.remote_enable = 1
    xdebug.remote_host = 10.1.1.1
    xdebug.remote_port= 9000
    xdebug.remote_autostart = 1

    # restart apache
    $ sudo /etc/init.d/apache2 restart

    Quelques explications :

    - zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so
    il faut pointer vers le path absolu où a été installé la lib xdebug

    - xdebug.idekey = by_lamp
    by_lamp sera la clef de la session de debug

    - xdebug.remote_enable = 1
    xdebug.remote_host = 10.1.1.1
    xdebug.remote_port= 9000
    Active Xdebug, qui envoie les informations de debug sur notre machine (c'est à dire notre IDE qui écoute à l'IP 10.1.1.1, port 9000)

    - xdebug.remote_autostart = 1
    Xdebug va automatiquement demarer une session de debug pour chaque chargement et il n'est plus necessaire de passer en GET/POST/COOKIE la variable d'activation de Xdebug à chaque chargement de page

    # Configuration de PhpStorm pour debugger

    Il faut ensuite rajouter et matcher chaque site par l'url d'hôte et par fichier sur XDebug, voici un exemple de configuration d'un site

    PhpStorm -> Preferences ...
    Project Settings -> PHP -> Servers

    Maintenant, le debugger est configuré pour l'hôte symfony.test.dev. Pour tester le debugger sur PhpStorm :

    Run -> Start Listen PHP Debug Connections
    Run -> Break at first line in PHP scripts

    Sur votre navigateur favori, tapez l'url de la home : http://symfony.test.dev/app_dev.php

    Vous devriez maintenant avoir le retour de debug de la page par PhpStorm :

    Note :

    Pour debugger en ligne de commande, afin de conserver le système de path mapping, il faut rajouter la variable d'environnement suivante :

    $ PHP_IDE_CONFIG=serverName=symfony.test.dev php app/console