Is there a way to debug RabbitMQ Consumer (php-ampqlib) using PhpStorm and Xdebug?

Here is my dev setup:

IDE: PhpStorm 9.0.2
Debugger: Xdebug 2.3.3
Message Queuing Server: RabbitMQ 3.5.6
PHP lib to connect to RabbitMQ server: php-ampqlib

To run my consumer, I use the CakePHP task and do the following:

../lib/Cake/Console/cort cron message_trigger_consumer

When I run this command, my consumer is UP and is waiting for a message that will come from Producer (for example: the "Save form" button, which sends an email with confirmation). Everything is still fine, but my two questions are:

1) Is there a way to debug a Consumer ? From my point of view, Consumer is working in a different process, so Xdebug cannot debug it
2) Is there a way to bind my Consumer process to my current debugging in PhpStorm + Xdebug?

If you do not understand my question, please show me your doubts.

+5
source share
2 answers

In the Xdebugs Web context, Sessions typically run a cookie called XDEBUG_SESSION .

There are no cookies in the CLI, so you will need to tell xdebug to start a session manually:

 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 for incoming connections through the handset icon.

Works great!

+2
source

Xdebug and RabbitMQ Commands

Running cake cron message_trigger_consumer does not call xdebug in the IDE. To tell PhpStorm about the connection, you need the command prefix with the environment variable:

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

Replace example.com with the appropriate server name.

0
source

Source: https://habr.com/ru/post/1234792/


All Articles