Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 Queue Server: RabbitMQ 3.5.6
PHP Lib to connect to RabbitMQ Server: php-ampqlib

To start my consumer I'm using a CakePHP Task and run like this:

../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? In my point of view, Consumer is in a different process, that's why Xdebug cannot debug it
2) Have some way to attach my Consumer process to my current debug in PhpStorm + Xdebug?

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

like image 496
Luiz Paulo Camargo Avatar asked Oct 29 '15 14:10

Luiz Paulo Camargo


People also ask

How do I debug using xdebug?

You can find it in the extension window and install it. After installation, you must reload the VSCode window. Now, again run phpinfo(); method in any PHP file to check if Xdebug is enabled or not. Now click on the debug console tab and click on add configuration.

What is Xdebug_session_start Phpstorm?

Google Dork Description: inurl:?XDEBUG_SESSION_START=phpstorm. Google Search: inurl:?XDEBUG_SESSION_START=phpstorm. #Google Dork : inurl:?XDEBUG_SESSION_START #Summary: Xdebug is a php extension that allows to debug php pages, remotely by using DGBp protocol. -


1 Answers

In Web Context Xdebugs Sessions are usually triggered by an Cookie named XDEBUG_SESSION.

On The CLI there are no cookies, so you will have to tell xdebug to start a session by hand:

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.

Its working great!

like image 56
mblaettermann Avatar answered Nov 05 '22 06:11

mblaettermann