PHP code example of amine-lejmi / messenger-maker

1. Go to this page and download the library: Download amine-lejmi/messenger-maker 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/ */

    

amine-lejmi / messenger-maker example snippets


// config/bundles.php

return [
    // ...
    AmineLejmi\MessengerMaker\MessengerMakerBundle::class => ['all' => true],
];



namespace App\Messenger\Command;

class SendEmailCommand
{
    private string $address;
    private ?string $message;

    public function __construct(string $address, ?string $message)
    {
        $this->address = $address;
        $this->message = $message;
    }

    public function getAddress(): string
    {
        return $this->address;
    }

    public function getMessage(): ?string
    {
        return $this->message;
    }
}



namespace App\Messenger\CommandHandler;

use AmineLejmi\MessengerMaker\Contract\CommandHandlerInterface;
use App\Messenger\Command\SendEmailCommand;

class SendEmailCommandHandler implements CommandHandlerInterface
{
    public function __construct()
    {
    }

    public function __invoke(SendEmailCommand $command)
    {
        $address = $command->getAddress();
        $message = $command->getMessage();
        
        // Do something with your variables 
    }
}