Repository navigation
D8 D7 Debugging
- Antes de nada: Apaga el firewall por si las moscas!
- Activa suggestions desde el settings / services
Para configurar XDEBUG 3 en PHPSTORM hay que ir comprobando pasito a paso cada opción de configuración.
Si falla mirar esto:
- Este link te explica paso a paso lo que hay que hacer en PHPSTORM: https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html#on_demand_mode
- Es importante crear en el root un fichero info.php y que se pueda cargar desde la web. Primero meter ahí el breakpoint. En dicha página web ver bien las configuraciones que se están usando
- Ver bien si podemos usar las siguientes opciones (en xdebug 3.1 NO se deben de activar)
- Enable return function value debugging
- Ignore external connections
-
Desde File > Settings > PHP seleccionar
- PHP 7.4
- CLI Interpreter: (no interpreter)
-
Desde File > Settings > PHP > Debug
- Seguir los 4 pasos.
- Debug Port: 9000 (no usar 9003 con devilbox)
- Al hacer el validation script (no es obligatorio hacerlo) usar los siguientes datos:
- Path to script: /home/pierre/webapps/devilbox/data/www/drupal-9/web
- Url: http://drupal-9.loc
Te dirá las cosas que te faltan. En mi caso me dice que debo usar "172.16.238.1" para la variablexdebug.client_host
-
Desde File > Settings > PHP > Debug > DBGp Proxy usar lo siguiente:
- IDE KEY : PHPSTORM
- Host: 0.0.0.0
- Port: 9000
-
Desde *File > Settings > PHP > Servers * creamos un nuevo Server (no siempre hace falta, hay veces que el propio IDE al reconocer la llamada te lo autorellena)
- Host: drupal-9.loc
- Port: 80
- Debugger: Xdebug
- Relacionamos Path Mapping (esto es muy importante hacerlo bien): /home/pierre/webapps/devilbox/data/www/drupal-9/web /shared/httpd/drupal-9/web
No hace falta crear ninguna configuración. Toma la de por defecto creada en el Settings general.
En cuanto al php.ini he usado estos datos:
; Configuraciones para xdebug 3
xdebug.mode = debug,profile
xdebug.start_with_request = yes
xdebug.client_port = 9000
xdebug.idekey = PHPSTORM
xdebug.log = /var/log/php/xdebug.log
;No hace falta (al menos usando MYIP en pasos posteriores)
;xdebug.client_host = 172.16.238.1
;xdebug.client_host = 192.168.1.134
#!/bin/sh
#sudo service apache2 stop # tengo apache local
#sudo service mysql stop # tengo mysql local
# Obtener la IP de mi máquina (no se si hace falta)
export MYIP=$(ip route get 1 | sed 's/^.*src \([^ ]*\).*$/\1/;q')
echo $MYIP
cd ~/webapps/devilbox
cp env74 .env
docker-compose up mysql httpd php bind
En macOS:
ifconfig en0 | grep inet | awk '$1=="inet" {print $2}'
No se si haga falta, pero añade variable DEBUG y IP del host (mi máquina local)
services:
php:
environment:
- XDEBUG_CONFIG=client_host=${MYIP}
- DEBUG=1
Mas info vieja en:
https://github.com/pierregermain/MyDrupal/wiki/IDE-INTEGRATION-with-VAGRANT
En la documentación de devilbox dicen que hay que hacer redirects usando ssh -i que a mi nunca me ha echo falta.
Abrimos un túnel haciendo
sshpass -p your-password ssh -p2220 your-user@your-remote-host -R 9002:127.0.0.1:9002
-
Requisitos:
- Tener la extensión de xdebug de PHP instalada / habilitada
- Instalar felixfbecker.php-debug extension
-
Ver configuración de PHP en http://drupal-7.loc/admin/reports/status/php
-
Meterle un
echo "hola";die();al principio de tuindex.phppara ver que entra en tu código. -
Tienes que meterle un PHP DEGUG configuration file a tu visual studio. Si por error metes uno para node js tienes que borrarlo desde el sistema de ficheros (en la carpeta
.vscode) -
Ahora si: Puedes agregar un breakpoint a tu código.
-
Misc:
- Si no te va hay un wizard (copias y pegas el output del php info) y te dice lo que te falta
-
Info en devilbox https://devilbox.readthedocs.io/en/latest/intermediate/configure-php-xdebug/toolbox/vscode.html#configure-php-xdebug-toolbox-vscode
https://www.drupal.org/docs/7/theming/overriding-themable-output/working-with-template-suggestions
Es práctico usar mensajes del tipo:
drush_log('Valor Variable: '.$variable, 'warning');
Instalar e desinstalar de la siguiente forma el módulo:
clear;drush cc all; drush en -y NOMBRE_MODULO;drush cc all;
clear;drush cc all; drush pm-disable -y NOMBRE_MODULO;drush pm-uninstall -y NOMBRE_MODULO;