PHP code example of jhyangxyz / messenger-version-control

1. Go to this page and download the library: Download jhyangxyz/messenger-version-control 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/ */

    

jhyangxyz / messenger-version-control example snippets




return [
    ...,
    Jhyangxyz\MessengerVersionControl\JhyangxyzMessengerVersionControlBundle::class => ['all' => true],
];




namespace App\Message;

use Jhyangxyz\MessengerVersionControl\Message\AbstractVersionedMessage;

final class FooMessage extends AbstractVersionedMessage
{
    public function __construct()
    {
        $this->setVersion();
    }

    public function getBuildVersion(): int
    {
        return 1;
    }
}



namespace App\MessageHandler;


use Jhyangxyz\MessengerVersionControl\MessageHandler\AbstractVersionedMessageHandler;


final class FooMessageHandler extends AbstractVersionedMessageHandler
{
    public function __invoke(FooMessage $message)
    {
        $this->checkVersion($message);  
        
        //Handle message
        ...
    }
}