PHP code example of wexample / symfony-live

1. Go to this page and download the library: Download wexample/symfony-live 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/ */

    

wexample / symfony-live example snippets


use Wexample\SymfonyLive\Interface\LiveEntityNormalizerInterface;

class DefaultMessageNormalizer extends AbstractEntityNormalizer implements LiveEntityNormalizerInterface
{
}

use Wexample\SymfonyLive\Enum\LiveTopicAction;
use Wexample\SymfonyLive\Helper\LiveTopicHelper;
use Wexample\SymfonyLive\Service\LivePublisherService;

public function __construct(
    private readonly LivePublisherService $publisher,
) {
}

$this->publisher->publishEvent(
    LiveTopicHelper::entity($session, LiveTopicAction::EVENT),
    'message.save',
    $this->messageNormalizer->normalize($message)
);

use Wexample\SymfonyLive\Attribute\LiveEntity;

#[ORM\Entity(repositoryClass: SessionRepository::class)]
#[LiveEntity(actions: [LiveTopicAction::EVENT])]
class Session extends AbstractEntity
{
}