macでxdebugをインストール

13256 ワード

環境:macパソコン、php 7.2.16
公式サイトのインストール方法は
pecl install xdebug

ヒントはpeclがないのでpeclをインストールしなければなりません
cd src
curl -o go-pear.php https://pear.php.net/go-pear.phar  

ここでのダウンロードソースのコンパイルはすべて~/srcの下に統一されています.もしダウンロードに失敗したら、一般的にはウェブサイトの間違いです.ダウンロードしたページは正しいウェブサイトがどこにあるか教えてくれます.ここではコマンドsudo php go-pearを実行します.phpの後ろに記入した内容は1回/usr/local/pear回車4回/usr/local/bin回車回車
➜  src sudo php go-pear.php

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /usr/local
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/local/bin
 5. PHP code directory ($php_dir)                 : /usr/local/lib/php
 6. Documentation directory                       : /usr/local/docs
 7. Data directory                                : /usr/local/data
 8. User-modifiable configuration files directory : /usr/local/cfg
 9. Public Web Files directory                    : /usr/local/www
10. System manual pages directory                 : /usr/local/man
11. Tests directory                               : /usr/local/tests
12. Name of configuration file                    : /usr/local/etc/pear.conf

1-12, 'all' or Enter to continue: 1
(Use $prefix as a shortcut for '/usr/local', etc.)
Installation base ($prefix) [/usr/local] : /usr/local/pear

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /usr/local/pear
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/local/pear/bin
 5. PHP code directory ($php_dir)                 : /usr/local/pear/lib/php
 6. Documentation directory                       : /usr/local/pear/docs
 7. Data directory                                : /usr/local/pear/data
 8. User-modifiable configuration files directory : /usr/local/pear/cfg
 9. Public Web Files directory                    : /usr/local/pear/www
10. System manual pages directory                 : /usr/local/pear/man
11. Tests directory                               : /usr/local/pear/tests
12. Name of configuration file                    : /usr/local/etc/pear.conf

1-12, 'all' or Enter to continue: 4
(Use $prefix as a shortcut for '/usr/local/pear', etc.)
Binaries directory [$prefix/bin] : /usr/local/bin

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /usr/local/pear
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/local/bin
 5. PHP code directory ($php_dir)                 : /usr/local/pear/lib/php
 6. Documentation directory                       : /usr/local/pear/docs
 7. Data directory                                : /usr/local/pear/data
 8. User-modifiable configuration files directory : /usr/local/pear/cfg
 9. Public Web Files directory                    : /usr/local/pear/www
10. System manual pages directory                 : /usr/local/pear/man
11. Tests directory                               : /usr/local/pear/tests
12. Name of configuration file                    : /usr/local/etc/pear.conf

1-12, 'all' or Enter to continue:
Beginning install...
Configuration written to /usr/local/etc/pear.conf...
Initialized registry...
Preparing to install...
installing phar:///Users/apple/src/go-pear.php/PEAR/go-pear-tarballs/Archive_Tar-1.4.8.tar...
installing phar:///Users/apple/src/go-pear.php/PEAR/go-pear-tarballs/Console_Getopt-1.4.3.tar...
installing phar:///Users/apple/src/go-pear.php/PEAR/go-pear-tarballs/PEAR-1.10.10.tar...
installing phar:///Users/apple/src/go-pear.php/PEAR/go-pear-tarballs/Structures_Graph-1.1.1.tar...
installing phar:///Users/apple/src/go-pear.php/PEAR/go-pear-tarballs/XML_Util-1.4.3.tar...
install ok: channel://pear.php.net/Archive_Tar-1.4.8
install ok: channel://pear.php.net/Console_Getopt-1.4.3
install ok: channel://pear.php.net/Structures_Graph-1.1.1
install ok: channel://pear.php.net/XML_Util-1.4.3
install ok: channel://pear.php.net/PEAR-1.10.10
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

The 'pear' command is now at your service at /usr/local/bin/pear

上のpeclはインストールに成功しました.xdebugをインストールできます.
➜  src sudo pecl install xdebug
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading xdebug-2.9.3.tgz ...
Starting to download xdebug-2.9.3.tgz (243,540 bytes)
..................................................done: 243,540 bytes
91 source files, building
running: phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
building in /private/tmp/pear/install/pear-build-rootAmGpCP/xdebug-2.9.3
running: /private/tmp/pear/install/xdebug/configure --with-php-config=/usr/local/bin/php-config

インストールが完了したらphp.iniに追加(php-i|grep php.iniコマンドでphp.iniのパスを取得できます)
vim /usr/local/lib/php.ini

[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_connect_back=0
xdebug.remote_host=0.0.0.0
xdebug.remote_port=9001
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_enable_trigger_value=666
xdebug.profiler_output_dir=/Users/apple

phpを再起動
➜  src sudo killall php-fpm
➜  src sudo /usr/local/sbin/php-fpm

phpinfo()を見るとxdebugが見えます