web-dev-qa-db-fra.com

Installer XDebug pour PHP avec XAMPP sur Mac

J'ai un Mac avec une nouvelle installation OSX Mojave. J'ai téléchargé XAMPP (7.3) et installé. Le serveur Web Apache local fonctionne et le PHPInfo () que je récupère dans le tableau de bord montre toutes les informations correctes du fichier php.ini, à savoir /Applications/XAMPP/xamppfiles/etc/php.ini. 

J'ai pris une copie de PHPInfo et je l'ai mise dans l'assistant à l'adresse suivante: 

https://xdebug.org/wizard.php

Les instructions ont l'air simple. J'ai d'abord dû utiliser homebrew pour installer autoconf.

Mais ensuite, j'ai pu télécharger et décompresser le fichier xdebug-2.6.1.tgz dans le dossier/Applications/XAMPP/xamppfiles /.

J'ai changé ma variable $ PATH pour que/Applications/XAMPP/xamppfiles/bin soit le premier chemin recherché, afin que la phpize correcte soit exécutée.

J'ai changé pour le dossier /Applications/XAMPP/xamppfiles/xdebug-2.6.1 et ai couru phpize, puis j'ai couru ./configure. Tout semblait bien fonctionner, sans aucune erreur perçue.

Mais alors j'ai eu des erreurs quand j'ai exécuté la commande "make". Voici le résultat obtenu:

> Terrys-MacBook-Pro:xdebug-2.6.1 terry$ make /bin/sh
> /Applications/XAMPP/xamppfiles/xdebug-2.6.1/libtool --mode=compile cc 
> -I. -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -DPHP_ATOM_INC -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/include -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/main -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -I/Applications/XAMPP/xamppfiles/include/php -I/Applications/XAMPP/xamppfiles/include/php/main -I/Applications/XAMPP/xamppfiles/include/php/TSRM -I/Applications/XAMPP/xamppfiles/include/php/Zend -I/Applications/XAMPP/xamppfiles/include/php/ext -I/Applications/XAMPP/xamppfiles/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c -o
> xdebug_compat.lo   cc -I.
> -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -DPHP_ATOM_INC -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/include -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/main -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -I/Applications/XAMPP/xamppfiles/include/php -I/Applications/XAMPP/xamppfiles/include/php/main -I/Applications/XAMPP/xamppfiles/include/php/TSRM -I/Applications/XAMPP/xamppfiles/include/php/Zend -I/Applications/XAMPP/xamppfiles/include/php/ext -I/Applications/XAMPP/xamppfiles/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c 
> -fno-common -DPIC -o .libs/xdebug_compat.o /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c:56:71:
**> error: too few arguments to function call, expected 6, have 5**
>         return zend_get_zval_ptr(op_type, node, zdata, &should_free, BP_VAR_R);
>                ~~~~~~~~~~~~~~~~~                                             ^
> /Applications/XAMPP/xamppfiles/include/php/Zend/zend_execute.h:330:1:
> note: 'zend_get_zval_ptr' declared here ZEND_API zval
> *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type); ^ /Applications/XAMPP/xamppfiles/include/php/main/php_config.h:9:19:
> note: expanded from macro 'ZEND_API'
> # define ZEND_API __attribute__ ((visibility("default")))
>                   ^ /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c:194:88:
> error: too few arguments to function call, expected 9, have 8
>         php_setcookie(name_s, value_s, expires, path_s, domain_s, secure, url_encode, httponly);
>         ~~~~~~~~~~~~~                                                                         ^ /Applications/XAMPP/xamppfiles/include/php/ext/standard/head.h:40:1:
> note: 'php_setcookie' declared here PHPAPI int
> php_setcookie(zend_string *name, zend_string *value, time_t expires,
> zend_string *path, zend_string *domain, int secure, int httponly,
> zend_string *samesite, int url_encode); ^
> /Applications/XAMPP/xamppfiles/include/php/main/php.h:72:18: note:
> expanded from macro 'PHPAPI'
> #               define PHPAPI __attribute__ ((visibility("default")))
>                               ^ 2 errors generated. make: *** [xdebug_compat.lo] Error 1

La première erreur que je vois dans la commande "make" est donc "> erreur: trop peu d'arguments pour appeler une fonction, on attend 6, on a 5".

Je ne sais pas ou aller d'ici. Les documents sans fin que j'ai lus semblent être pour PC ou pour PHP 5. 

6
TBone

Il y a un bug pour cela. Le lien est donc: https://bugs.xdebug.org/view.php?id=1593

Ce qui décrit que vous devez utiliser Xdebug 2.7.0beta1 pour le moment.

7
Hannibal

Hannibal a raison, mais sa réponse est un peu succincte et je voudrais donc en dire un peu plus long.

Ceci est un bogue XDebug pour PHP 7.3.x, vous devrez donc installer XDebug 2.7.0beta1:

$ pecl install xdebug-2.7.0beta1

Depuis que j'ai installé la dernière version PHP avec Homebrew, l'installation de XDebug a en fait jeté deux erreurs mkdir(). En effet, il existait déjà un lien symbolique pecl dans le répertoire PHP de Homebrew.

Je voulais d'abord vérifier cela, alors j'ai exécuté $ ls -al /usr/local/Cellar/php/<YOUR_PHP_VERSION_NUMBER>

Si vous avez des doutes sur votre version PHP, vous devez l’inscrire dans le journal d’installation pecl et l’indiquer à côté des erreurs mkdir().

Une fois que j'ai confirmé qu'il y avait déjà un lien symbolique, je l'ai simplement supprimé:

$ rm /usr/local/Cellar/php/<YOUR_PHP_VERSION_NUMBER>/pecl

Après cela, j'ai relancé l'installation et tout s'est bien passé.

Bien sûr, $ php --ini a montré des erreurs, je devais donc configurer PHP correctement. Gabor Javorsky a en fait écrit un excellent article qui explique comment s'assurer que XDebug est chargé correctement et que cela a parfaitement fonctionné pour moi. Voir Step 2 dans son article ici: https://javorszky.co.uk/2018/05/03/getting-xdebug-working-on-php-7-2-and-homebrew/ .

N'oubliez pas de recharger PHP après avoir peaufiné votre configuration, qui était pour moi:

$ brew services stop [email protected] && brew services start [email protected]

Après cela, $ php --ini ne devrait afficher aucune erreur!

0
cfx