campusdomar/pmk2-cmar-live-bundle
Install via Composer
composer require campusdomar/pmk2-cmar-live-bundle
Ensure your project meets Symfony 5.4+ and Laravel 8+ (via Symfony Bridge) requirements.
Enable the Bundle
In config/bundles.php (Symfony) or bootstrap/app.php (Laravel):
return [
// ...
CampusDomar\PuMuKIT2\CMARLiveBundle\PuMuKIT2CMARLiveBundle::class => ['all' => true],
];
First Use Case: Embed a Live Stream with Chat
config/packages/pumukit2_cmar_live.yaml (default paths: config/packages/).{{ include('@PuMuKIT2CMARLive/Player/player.html.twig', {
'streamKey': 'your_stream_key',
'chatEnabled': true
}) }}
// routes/web.php
Route::get('/live/{stream}', [LiveController::class, 'show']);
// LiveController.php
public function show($stream) {
return view('live.player', ['streamKey' => $stream]);
}
Stream Management
Pumukit\LiveBundle\Manager\LiveManager service to start/stop streams programmatically:
$liveManager = $this->container->get('pumukit.live.manager');
$liveManager->startStream('your_stream_key');
$this->app->bind('pumukit.live.manager', function ($app) {
return new \Pumukit\LiveBundle\Manager\LiveManager(
$app['pumukit.live.configuration']
);
});
Chat Integration
{# Enable chat with custom CSS/JS #}
{{ include('@PuMuKIT2CMARLive/Player/chat.html.twig', {
'chatTheme': 'dark',
'moderators': ['admin@example.com']
}) }}
document.addEventListener('pumukitChatMessage', (e) => {
console.log('New message:', e.detail);
});
Customization
vendor/campusdomar/pmk2-cmar-live-bundle/Resources/views/
to templates/PuMuKIT2CMARLive/.# config/packages/pumukit2_cmar_live.yaml
pumukit2_cmar_live:
player:
default_chat_position: 'bottom-right'
allowed_chat_commands: ['!kick', '!ban']
API-Driven Workflows
# Example: Start a stream via HTTP
POST /api/live/start
Headers: Authorization: Bearer {token}
Body: { "streamKey": "your_key" }
Symfony vs. Laravel Integration
AppServiceProvider:
public function register() {
$this->app->register(\Symfony\Bundle\FrameworkBundle\FrameworkBundle::class);
$this->app->boot();
}
symfony/var-dumper for debugging:
use Symfony\Component\VarDumper\Cloner\VarCloner;
$cloner = new VarCloner();
$cloner->dump($this->container->get('pumukit.live.manager'));
Chat Permissions
chat_moderators) and fetch them dynamically:
{% set moderators = app.service('moderator.repository').findByStream(streamKey) %}
Stream Key Validation
public function rules() {
return ['streamKey' => 'required|regex:/^[a-z0-9_-]{8,}$/'];
}
Template Overrides
php bin/console cache:clear
Or Laravel’s:
php artisan cache:clear
php artisan view:clear
APP_DEBUG=true in .env and check Symfony’s profiler at /_profiler.config/packages/monolog.yaml:
handlers:
chat:
type: stream
path: "%kernel.logs_dir%/chat.log"
level: debug
channels: ["pumukit_chat"]
ws:// endpoints).Custom Chat Commands Extend the chat system by creating a command handler:
namespace App\Chat;
class CustomCommandHandler implements \Pumukit\LiveBundle\Chat\CommandHandlerInterface {
public function handle(string $command, string $sender): ?string {
if (str_starts_with($command, '!custom')) {
return "Custom response for $sender";
}
return null;
}
}
Register it in services.yaml:
services:
App\Chat\CustomCommandHandler:
tags: ['pumukit.chat.command_handler']
Webhook Integration Trigger external actions (e.g., Slack alerts) when chat events occur:
// config/packages/pumukit2_cmar_live.yaml
pumukit2_cmar_live:
chat:
webhooks:
- url: 'https://hooks.slack.com/...'
events: ['message', 'moderation']
Laravel Notifications Convert chat messages to Laravel notifications:
use Pumukit\LiveBundle\Event\ChatMessageEvent;
public function onChatMessage(ChatMessageEvent $event) {
Notification::route('mail', $event->getSender())
->notify(new ChatMessageNotification($event));
}
Register the listener in EventServiceProvider.
How can I help you explore Laravel packages today?