2
1

More than 5 years have passed since last update.

【EC-CUBE4】⑤EC-CUBE本体の開発環境を整える(Xdebug, PhpStorm編)

Last updated at Posted at 2019-08-05

EC-CUBE4の環境構築続きです。
【EC-CUBE4】①EC-CUBE本体の開発環境を整える(インストール編)
【EC-CUBE4】②EC-CUBE本体の開発環境を整える(GitHub Flow編)
【EC-CUBE4】③EC-CUBE本体の開発環境を整える(MYSQL,MailCatcher編)
【EC-CUBE4】④EC-CUBE本体の開発環境を整える(Postgres,MailCatcher編)

前提条件

方針

  • webサーバーはビルドインウェブサーバーを利用。

xdebugのモジュールを有効にする

$ php -S localhost:8000
$ php -v
PHP 7.2.8 (cli) (built: Jun 19 2019 14:35:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.8, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.7.1, Copyright (c) 2002-2019, by Derick Rethans
$ php -m
[Zend Modules]

php -mでXdebugのモジュールがなければ、エクステンションを有効にします。

まずは設定を確認します。

$ php --ini
Configuration File (php.ini) Path: /Users/<ユーザー名>/.phpenv/versions/7.2.8/etc
Loaded Configuration File:         /Users/<ユーザー名>/.phpenv/versions/7.2.8/etc/php.ini
Scan for additional .ini files in: /Users/<ユーザー名>/.phpenv/versions/7.2.8/etc/conf.d
Additional .ini files parsed:      /Users/<ユーザー名>/.phpenv/versions/7.2.8/etc/conf.d/xdebug.ini
$ vim /Users/<ユーザー名>/.phpenv/versions/7.2.8/etc/conf.d/xdebug.ini

xdebug.iniに以下を追記します。

[Xdebug]
xdebug.remote_enable=true
xdebug.remote_autostart = On
xdebug.remote_port=9001
xdebug.remote_host=localhost
xdebug.idekey = "PHPSTORM"

サーバーを再起動します。

$ php -S localhost:8000
$ php -m
[Zend Modules]
Xdebug

Xdebugのモジュールが表示されていればOKです。

PhpStormの設定

Preferences

Preferences > Languages & Frameworks > PHP より、CLI Interpreterを設定します。

下図のような感じです。

スクリーンショット 2019-08-05 22.06.09.png

CLI Interpreterが設定されました。

スクリーンショット 2019-08-05 22.05.51.png

次に、
Preferences > Languages & Frameworks > PHP > Debug より、Debug portを9001に設定します。

スクリーンショット 2019-08-05 22.07.24.png

Preferences > Languages & Frameworks > PHP > Servers より、下図のように設定します。

スクリーンショット 2019-08-05 22.07.39.png

Edit Configurations

Edit Configurationsを設定します。

Run > Edit Configurations より、ServerとIDE keyを設定します。

スクリーンショット 2019-08-05 22.08.11.png

動作確認

PhpStorm右上の電話マークをオンにしてください。
その後、図のようにソースの左側にブレークポイントを張って、ブラウザで、画面遷移します。
処理が走ると、ブレークポイントで処理が止まります。
下図のようになれば、デバッグが成功しています。

スクリーンショット 2019-08-05 22.19.42.png

注意点

EC-CUBE4の管理画面からプラグインをインストールする際に、Xdebugが有効になっているとインストールに失敗します。

プラグインをインストールする際は、Xdebugを無効にしてから、インストールするようにしましょう。

次回

【EC-CUBE4】⑥EC-CUBE本体の開発環境を整える(Codeception編)をお送りします。

2
1
0

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
2
1