1. Go to this page and download the library: Download hibira-io/symfony-bundle 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/ */
hibira-io / symfony-bundle example snippets
use Symfony\UX\Turbo\Attribute\Broadcast;
#[ORM\Entity]
#[Broadcast]
class Message
{
// ...
}
public function __construct(private Hibira $hibira) {}
$this->hibira->turboStream('import-42', '<turbo-stream action="update" target="progress"><template>80%</template></turbo-stream>');
use Hibira\SymfonyBundle\Hibira;
$hibira->publish('private-orders.42', 'shipped', ['id' => 42]);
use Hibira\SymfonyBundle\Event\ChannelAuthorizationEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
#[AsEventListener]
final class AuthorizeChannels
{
public function __invoke(ChannelAuthorizationEvent $event): void
{
if ($event->channel === 'private-orders.'.$event->user?->getId()) {
$event->allow();
}
if ($event->channel === 'presence-team' && $event->user !== null) {
// Member ID defaults to the user identifier.
$event->allow(memberInfo: ['name' => $event->user->getName()]);
}
}
}
#[AsEventListener]
public function onWebhook(WebhookReceivedEvent $event): void
{
if ($event->name === 'member_removed') {
// $event->channel, $event->payload['user_id']
}
}