symfony/doctrine-messenger
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
doctrine/dbal | 4.0.2 | - | MIT | prod | |
symfony/messenger | v7.0.7 | - | MIT | prod | |
symfony/service-contracts | v3.5.0 | - | MIT | prod dev |
The Symfony Doctrine Messenger is a powerful tool that allows seamless integration between Symfony Messenger and Doctrine. Symfony Messenger is a potent component of Symfony that aids in sending and receiving messages between applications, while Doctrine is a set of PHP libraries intended to manage databases. Thus, by enabling a smooth interface between the two, Symfony Doctrine Messenger works as a bridge, thus improving the scalability of your Symfony applications and enhancing the potential of your database handling and application messaging.
Working with Symfony Doctrine Messenger isn't overly complex if you're familiar with Symfony and Doctrine. To start with, you need to have the Messenger and Doctrine bundles set up in your Symfony application.
composer require symfony/messenger doctrine
Once you have them installed, you can configure your messenger transport to use the doctrine transport like this:
# config/packages/messenger.yaml
framework:
messenger:
transports:
async_priority_high:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
queue_name: high
async_priority_low:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
queue_name: low
routing:
'App\Message\YourMessage': async_priority_high
In your MessageHandler, use the Entity Manager to persist your entities. When dispatching the message, the Symfony Messenger automatically determines the correct MessageHandler.
class YourMessageHandler implements MessageHandlerInterface
{
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}
public function __invoke(YourMessage $message)
{
// use the entity manager to persist your entities
}
}
The Symfony Doctrine Messenger documentation can be found within Symfony's comprehensive online docs. More specifically, you can access Symfony Doctrine Messenger's dedicated resources by visiting Symfony's official documentation. You can also find relevant contribution guidelines, report any issues, and propose pull requests on the main Symfony repository on GitHub.