I'm working with a Magento 2 queue at the moment. To debug Magento 2 console scripts I normally just hit 'listen to external connections' in PHPstorm and execute the CLI script (i'm using Valet+ with Xdebug on Mac).

With the new queue system of Magento 2.3 this, however, doesn't work. When I start my normal debugging workflow and I start queue processing with bin/magento queue:consumers:start someConsumer and PHPstorm stops at the first line of \Magento\MessageQueue\Console\StartConsumerCommand::execute:

Xdebug session with PHPstorm

But it never reaches my actual consumer class. In my case this is Vendor\Module\Model\Queue\Consumer::processMessage (as specified in queue_consumer.xml). The processMessage function is executed, and the breakpoints aren't hit.

So, how do I setup Xdebug to debug queue consumers in Magento 2.3?


First verify XDebug is enabled for CLI PHP:

php -i | grep xdebug

Set these environment variables in the (SSH) shell of the Magento instance, you may need to change the port and host:

export PHP_IDE_CONFIG="serverName=Local_Mac"
export XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host= remote_connect_back=0"

Now you can execute CLI commands which will use the above XDebug settings:

php bin/magento queue:consumers:start

Or you can start a specific consumer, for example exportProcessor:

php bin/magento queue:consumers:start exportProcessor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.