diff --git a/.woodpecker/functional-tests.yml b/.woodpecker/functional-tests.yml index 7fb64f7..d76fef9 100644 --- a/.woodpecker/functional-tests.yml +++ b/.woodpecker/functional-tests.yml @@ -5,7 +5,7 @@ workspace: matrix: include: - FLOW_VERSION: 7.3 - PHP_VERSION: 8.2 + PHP_VERSION: 8.0 - FLOW_VERSION: 8.2 PHP_VERSION: 8.2 diff --git a/README.md b/README.md new file mode 100644 index 0000000..81be53a --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +# DigiComp.FlowSymfonyBridge.Messenger + +![Build status](https://ci.digital-competence.de/api/badges/Packages/DigiComp.FlowSymfonyBridge.Messenger/status.svg) + +This packages brings a DI configuration for the `symfony/messenger` component, so it can be used easily in `neos/flow` projects. + +To see how to use it, you probably want to have a look at the [documentation](https://symfony.com/doc/current/messenger.html) of `symfony/messenger`. + + +## Getting started + +To get it integrated, you all need to do is to get message bus injected: + +```php + #[Flow\Inject] + protected MessageBusInterface $messageBus; +``` + +And later in your method: + +```php + $this->messageBus->dispatch(new CustomMessage()) +``` + +You should configure a routing, to let the messenger know, over which transport your message should be handled: + +```yaml +DigiComp: + FlowSymfonyBridge: + Messenger: + transports: + "custom-messages": + dsn: "flow-doctrine://default?table_name=test_messenger_messages" + routing: + Acme\Vendor\Messenger\CustomMessage: + - "custom-messages" +``` + +In this example we are using a doctrine transport (the speciality "flow-transport" is a transport which uses the already existing connection to doctrine instead of creating a new one - for the rest of the DSN-Format have a look in the documentation of `symfony/messenger`) + +A handler for your CustomMessage could look like this: + +```php +use Symfony\Component\Messenger\Attribute\AsMessageHandler; + +#[AsMessageHandler] +class CustomMessageHandler +{ + public function __invoke(CustomMessage $message) + { + //your code here + } +} +``` + +It will be automatically found by Flow // the messenger and messages arriving at the bus will be handled by your handler. + +Probably you'll want to consume the messengers with long living processes or as a cronjob. The Flow command for that task is `messenger:consume` (more help available) diff --git a/composer.json b/composer.json index 1a00b8e..de657e5 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,9 @@ { "name": "digicomp/flow-symfony-bridge-messenger", "type": "neos-package", - "license": "MIT", "description": "Flow dependency injection bridge to symfony/messenger", "require": { - "php": "^8.1", + "php": "^8.0", "neos/flow": "^7.3 | ^8.0", "symfony/doctrine-messenger": "^6.2", "symfony/event-dispatcher": "^4.2 | ^5.2 | ^6.2" @@ -26,5 +25,21 @@ "neos": { "package-key": "DigiComp.FlowSymfonyBridge.Messenger" } - } + }, + "authors": [ + { + "name": "Ferdinand Kuhl", + "email": "f.kuhl@digital-competence.de", + "homepage": "https://www.digital-competence.de", + "role": "Developer" + } + ], + "license": "MIT", + "homepage": "https://github.com/digital-competence/DigiComp.FlowSymfonyBridge.Messenger", + "keywords": [ + "Neos", + "Flow", + "symfony", + "messenger" + ] }