RabbitMQ: Using PHP/Symfony to connect to RabbitMQ
This documentation is part of the Getting Started guide. You can view the complete guide here: How to use Stackhero for RabbitMQ.
If you are using Symfony, you can configure it to use RabbitMQ as a message broker by setting the MESSENGER_TRANSPORT_DSN environment variable. Simply update your .env file:
MESSENGER_TRANSPORT_DSN=amqps://<USER>:<PASSWORD>@<HOST>:<PORT>/%2f/messages?cacert=%2Fetc%2Fssl%2Fcerts%2Fca-certificates.crt
Replace
<USER>,<PASSWORD>,<HOST>, and<PORT>with your own RabbitMQ details.
Next, ensure your config/packages/messenger.yaml file uses the MESSENGER_TRANSPORT_DSN variable. It should look like this:
framework:
messenger:
transports:
async: '%env(MESSENGER_TRANSPORT_DSN)%'