PHP code example of ssch / t3-messenger

1. Go to this page and download the library: Download ssch/t3-messenger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ssch / t3-messenger example snippets



return [
    'failure_transport' => 'failed',
    'default_bus' => 'command.bus',
    'transports' => [
        'async' => [
            'dsn' => 'typo3-db://Default',
        ],
        'failed' => [
            'dsn' => 'typo3-db://Default',
            'options' => [
                'queue_name' => 'failed',
            ],
        ],
    ],
    'routing' => [
        MyCommand::class => ['senders' => ['async']],
    ],
    'buses' => [
        'command.bus' => [
            'middleware' => [
                'id' => 'validation',
            ],
        ],
        'query.bus' => [
            'default_middleware' => [
                'enabled' => true,
                'allow_no_handlers' => false,
                'allow_no_senders' => true,
            ],
        ],
    ],
];



return [
    'transports' => [
        'async' => [
            'dsn' => 'typo3-db://Default',
        ],
    ],
];


return [
    'buses' => [
        'messenger.bus.default' => [
            'middleware' => [
                'id' => 'validation',
            ],
        ],
    ],
];

return [
    'buses' => [
        'messenger.bus.default' => [
            'middleware' => [
                'id' => 'logging',
            ],
        ],
    ],
];


use TYPO3\CMS\Core\Mail\MailerInterface;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;

final class RegistrationService
{
    private MailerInterface $mailer;

    public function __construct(MailerInterface $mailer)
    {
        $this->mailer = $mailer;
    }

    public function register()
    {
        $mailMessage = GeneralUtility::makeInstance(MailMessage::class);
        $mailMessage->setTo('[email protected]');
        $mailMessage->setSubject('You MailerInterface');
        $this->mailer->send($mailMessage);
    }
}

return [
    'routing' => [
        \Symfony\Component\Mailer\Messenger\SendEmailMessage::class => ['senders' => ['async']],
    ]
]