OS X El CapitanにAtomでphpのデバッグ環境を構築
OS X El CapitanにAtomでphpのデバッグを可能にする環境構築手順を紹介します。
XDebugをインストール
Xdebug: Downloadsからインストール済みのPHPのバージョンに適用可能なバージョンのXDebugをダウンロードします。
自分の環境はPHP Version 5.5.34をインストール済みの為、Xdebug 2.4.0をダウンロードしました。
ターミナルを起動し、ダウンロードしたファイルのディレクトリに移動して以下のコマンドを実行します。
$ tar xvfz xdebug-2.4.0.tgz
$ cd xdebug-2.4.0
$ phpize
Configuring for: PHP Api Version: 20121113 Zend Module Api No: 20121212 Zend Extension Api No: 220121212 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
autoconfが見つからないというエラーが発生しました。
brewでautoconfをインストールして、エラーメッセージに表示されているように環境変数を設定します。
$ brew install autoconf $ export PHP_AUTOCONF=/usr/local/Cellar/autoconf/2.69/bin/autoconf
再度phpizeコマンドを実行します。
$ phpize
Configuring for: PHP Api Version: 20121113 Zend Module Api No: 20121212 Zend Extension Api No: 220121212 Cannot find autoheader. Please check your autoconf installation and the $PHP_AUTOHEADER environment variable. Then, rerun this script.
またエラーが発生しました。やれやれだぜ。。。
autoheaderは既に/usr/local/Cellar/autoconf/2.69/bin/autoheaderにインストール済みなので、autoconfと同様に、環境変数を設定します。
$ export PHP_AUTOHEADER=/usr/local/Cellar/autoconf/2.69/bin/autoheader
再度、phpizeを実行すると今度はエラーが発生せず、正常終了しました!
次に以下のコマンドを実行して、XDebugをコンパイルします。
$ ./configure --enable-xdebug
$ make
$ make install
同じディレクトリのmodulesディレクトリ以下に、xdebug.soが存在することを確認します。
以下のコマンドを実行して、xdebug.soをコピーします。
$ sudo cp modules/xdebug.so /usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
次にphp.iniを編集して、下記の内容を追加します。
$ vi /etc/php.ini
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so" xdebug.remote_enable=1 xdebug.remote_host=127.0.0.1 xdebug.remote_connect_back=1 xdebug.remote_port=9000 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_autostart=true
apacheを再起動します。
$ sudo apachectl graceful