简体   繁体   English

有没有办法使用PhpStorm和Xdebug调试RabbitMQ Consumer(php-ampqlib)?

[英]Is There a way to debug RabbitMQ Consumer (php-ampqlib) using PhpStorm and Xdebug?

Here is my dev setup: 这是我的开发设置:

IDE: PhpStorm 9.0.2 IDE: PhpStorm 9.0.2
Debugger: Xdebug 2.3.3 调试器: Xdebug 2.3.3
Message Queue Server: RabbitMQ 3.5.6 消息队列服务器: RabbitMQ 3.5.6
PHP Lib to connect to RabbitMQ Server: php-ampqlib PHP Lib连接到RabbitMQ服务器: php-ampqlib

To start my consumer I'm using a CakePHP Task and run like this: 为了启动我的消费者,我正在使用CakePHP任务并运行如下:

../lib/Cake/Console/cake cron message_trigger_consumer ../lib/Cake/Console/cake cron message_trigger_consumer

When I run this command, my consumer is UP and waiting for a message, that will comes from a Producer (for example: Save Form Button that send a confirmation email). 当我运行此命令时,我的消费者已启动并等待消息,该消息将来自生产者 (例如:发送确认电子邮件的保存表单按钮)。 Until here, everything is OK, but my two questions are: 直到这里,一切都很好,但我的两个问题是:

1) Is There a way to debug the Consumer ? 1)有没有办法调试消费者 In my point of view, Consumer is in a different process, that's why Xdebug cannot debug it 在我看来, 消费者处于一个不同的过程,这就是Xdebug无法调试它的原因
2) Have some way to attach my Consumer process to my current debug in PhpStorm + Xdebug? 2)有办法将我的Consumer流程附加到我在PhpStorm + Xdebug中的当前调试吗?

If you not understand my question, please, show me your doubts. 如果你不明白我的问题,请告诉我你的疑惑。

In Web Context Xdebugs Sessions are usually triggered by an Cookie named XDEBUG_SESSION . 在Web上下文中,Xdebugs会话通常由名为XDEBUG_SESSION的Cookie触发。

On The CLI there are no cookies, so you will have to tell xdebug to start a session by hand: 在CLI上没有cookie,因此您必须告诉xdebug手动启动会话:

export PHP_IDE_CONFIG="serverName=your-server-name-configured-in-php-storm"
export XDEBUG_CONFIG="remote_host=ip_of_php_storm_pc idekey=PHPSTORM"

Then in PHP Storm just listen to incoming connections via the phone handset icon. 然后在PHP Storm中,只需通过电话听筒图标收听传入的连接。

Its working great! 它的工作很棒!

Xdebug and RabbitMQ consumer commands Xdebug和RabbitMQ使用者命令

Running cake cron message_trigger_consumer doesn't trigger xdebug in the IDE. 运行cake cron message_trigger_consumer不会在IDE中触发xdebug。 To make PhpStorm aware of the connection you need to prefix the command with the environment variable: 要使PhpStorm知道连接,您需要在命令前添加环境变量:

PHP_IDE_CONFIG="serverName=example.com" cake cron message_trigger_consumer

Replace example.com with appropriate server name. 用适当的服务器名称替换example.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM