Xdebug / PhpstormでDrushスクリプトがブレークポイントで停止しない


6

私は別のDrupal VMでこれを機能させていましたが、何らかの理由でそれをもう機能させることができません。Drush移行スクリプトをデバッグしようとしていますが、いくつかのブレークポイントが設定されていますが、ブレークポイントで停止しません。ここに示す手順に従いました。

Vagrantのconfig.ymlのXdebugセクションは次のとおりです。

# XDebug configuration. XDebug is disabled by default for better performance.
php_xdebug_default_enable: 1
php_xdebug_coverage_enable: 1
php_xdebug_cli_enable: 1
php_xdebug_remote_enable: 1
php_xdebug_remote_connect_back: 1
php_xdebug_remote_host: xxx.xxx.xx.xx // My Vagrant IP is really here.
# Use PHPSTORM for PHPStorm, sublime.xdebug for Sublime Text.
php_xdebug_idekey: PHPSTORM
php_xdebug_max_nesting_level: 256

Webサーバーのデバッグ検証により、すべてが良好であることが示されます。また、ブラウザーからアクセスしたページをデバッグすると、ブレークポイントで停止するため、確実に機能することも確認しました。

また、PHP CLIにはXdebugがあります。

PHP 7.0.14-2+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.14-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

PHPの最初の行で改行するようにPhpstormを設定した場合、デバッガーで次の通知に気づきました。ソースの位置を計算できません。スクリプト「drush.phar」は、どのテキストファイルタイプにも関連付けられていません。

Xdebugログは次のとおりです。

Log opened at 2017-03-24 02:21:50
I: Connecting to configured address/port: 10.0.2.2:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/mysite/web/drush.phar" language="PHP" xdebug:language_version="7.0.14-2+deb.sury.org~xenial+1" protocol_version="1.0" appid="12759" idekey="18466"><engine version="2.5.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>

<- feature_set -i 1 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>

<- feature_set -i 2 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>

<- feature_set -i 3 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>

<- status -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="4" status="starting" reason="ok"></response>

<- step_into -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="5" status="break" reason="ok"><xdebug:message filename="file:///var/www/mysite/web/drush.phar" lineno="8"></xdebug:message></response>

<- breakpoint_set -i 6 -t line -f file:///var/www/mysite/web/modules/contrib/migrate_tools/migrate_tools.drush.inc -n 226
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="127590001"></response>

<- breakpoint_set -i 7 -t line -f file:///var/www/mysite/web/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php -n 22
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="127590002"></response>

<- breakpoint_set -i 8 -t line -f file:///var/www/mysite/web/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php -n 56
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="127590003"></response>

<- breakpoint_set -i 9 -t line -f file:///var/www/mysite/web/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php -n 37
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="127590004"></response>

<- stack_get -i 10
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="10"><stack where="{main}" level="0" type="file" filename="file:///var/www/mysite/web/drush.phar" lineno="8"></stack></response>

<- run -i 11
Log opened at 2017-03-24 02:21:51
I: Connecting to configured address/port: xxx.xxx.xx.xx:9000.
W: Creating socket for 'xxx.xxx.xx.xx:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2017-03-24 02:21:51

それを機能させるために何を試すことができるかについてのアイデアはありますか?

アップデート-私が試したこと

  • 迷惑なマシンを破壊し、やり直す
  • config.ymlのXdebug設定のさまざまな組み合わせ(デフォルトでの設定、remote_hostの削除、localhostの追加など)
  • ポートを9001に変更(PHPStormとVagrantの両方)

回答:


3

私はこの問題を抱えていました。これは、drushランチャー(https://github.com/drush-ops/drush-launcher)を使用していたために発生しました。このツールを使用すると、Drupalディレクトリに「./vendor/bin/drush」ではなく「drush」と入力できますが、xdebugを混乱させるようです。「./vendor/bin/drush」を使用して問題を修正しました。


これにより、正しいパスが得られました。また、コンテナに環境変数を設定する必要export PHP_IDE_CONFIG="serverName=MyServer"がありました。MyServerは、環境設定/言語とフレームワーク/ PHP /サーバーでパスマッピングを行うサーバーの名前です
Darvanen

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.