LoginSignup
22
29

More than 5 years have passed since last update.

atomでPHPのデバッグ

Posted at

PHPのビルトインサーバを使用して、atomでデバッグしてみた。

前提

下記がインストール済みであること
- PHP(5.4以上)
- Xdebug
- php-debug(atomのパッケージ)

設定

php.iniに以下の設定を追加する
※php.iniの場所がわからない場合はphpinfo()で確認

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

ビルトインサーバを起動

php.iniで設定したxdebugのportに合わせて起動する

php -S localhost:9000 -t [DocumentRootのフルパス]

または、ドキュメントルートに移動してから起動

cd [DocumentRootのフルパス]
php -S localhost:9000

atomでデバッグ

デバッグウィンドウを開く

cintrol+option+D(mac)、または画面下のPHP Debugをクリックしてデバッグウィンドウを開く
2016-07-16 00-46-12.png

ブレークポイントを設定する

対象行の左のエリアをクリックすると、ブレークポイントが設定できる
2016-07-16 00-31-46.png

対象ページにアクセスする

ブレークポイントで止まるので、あとはステップ実行など自由に操作
以下のように変数の内容も確認できる
2016-07-16 00-48-36.png

22
29
2

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
22
29