LoginSignup
16
14

More than 5 years have passed since last update.

Macにもともと入ってるPHP7.1にxdebugを入れる方法(2018年7月版)

Last updated at Posted at 2018-07-23

はじめに

愛用のhomebrew/phpリポジトリは廃止されたようです。。。

How to setup XDebug for PHP7 on Mac?

上記リンクにもあるように、現時点だとxdebugはpeclで入れるのがベストプラクティスっぽいです。

PHPはMacにもともと入ってるものを使います

/usr/bin/php

1. pearをインストール

xdebugはpeclコマンドで入るのですが、その前にpeclコマンドをインストールする必要があります。pearをインストールするとpeclがついでに入ってくるみたいなので今回はpearコマンドをインストールしてみます。

curl -O https://pear.php.net/go-pear.phar
php -d detect_unicode=0 go-pear.phar
sudo php /usr/lib/php/ install-pear-nozlib.phar

.bash_profileあたりに下記を記述してパスを通します

export PATH=$PATH:$HOME/pear/bin/

2. SIPをオフ

peclで/usr/lib配下をいじることになるのでmac os のSIPをリカバリーモードのターミナルから一時的にオフにします

csrutil disable

3. xdebugをインストール

pecl install xdebug

/etc/php.iniに設定を追記

zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so

下記コマンドでxdebugがインストールされているか確認

php -i | grep xdebug

4. csrutilをオンする

もう一度リカバリーモードに入ってSIPをオンにしておきます

csrutil enable

さいごに

上記のやり方でうまくいかないときはコメントください
できる範囲内でサポートしますm(_ _)m

16
14
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
14