bibsdb/sonderborg-calendar-bundle
Installation
Add the repository to composer.json under "repositories":
"repositories": {
"bibsdb/sonderborg-calendar-bundle": {
"type": "vcs",
"url": "https://github.com/bibsdb/sonderborg-calendar-bundle"
}
}
Require the bundle:
composer require bibsdb/sonderborg-calendar-bundle
Enable the Bundle
Register the bundle in config/bundles.php (Laravel 5.4+) or AppKernel.php (older versions):
Bibsdb\SonderborgCalendarBundle\BibsdbSonderborgCalendarBundle::class => ['all' => true],
Load the Template Run the command to load the slide template:
php artisan bibsdb:core:templates:load
Enable in Admin
Navigate to the administration panel (likely /admin) and enable the Sonderborg Calendar template.
Generate a Shared Link
Use the Template in a View Inject the template into a Twig view (or Blade if using a custom adapter):
{{ render(sonderborg_calendar_template, {
'video_url': 'https://sonderborg-calendar.com/embed/your-video-id',
'width': 800,
'height': 600
}) }}
Verify Output Check the rendered page to confirm the Sonderborg player loads correctly.
Dynamic Video Embedding
Video model) and pass them dynamically:
$videos = Video::where('is_public', true)->get();
return view('events.show', compact('videos'));
{% for video in videos %}
{{ render(sonderborg_calendar_template, {
'video_url': video.embed_url,
'width': 640,
'height': 360
}) }}
{% endfor %}
Reusable Components
resources/views/components/sonderborg-player.blade.php):
<div class="sonderborg-player">
{{ $slot }}
</div>
@script
<script>
document.addEventListener('DOMContentLoaded', function() {
SonderborgPlayer.init({{ json_encode($attributes->merge(['videoUrl' => $videoUrl])) }});
});
</script>
@endscript
<x-sonderborg-player video-url="$video->embed_url" width="800" height="450" />
Admin Integration
use Bibsdb\SonderborgCalendarBundle\Form\Type\SonderborgVideoType;
$formMapper
->add('video', SonderborgVideoType::class, [
'label' => 'Sonderborg Calendar Video',
'required' => false,
]);
Asset Management
resources/views/layouts/app.blade.php for:
@vite(['resources/js/sonderborg-player.js'])
vite.config.js:
resolve: {
alias: {
sonderborgPlayer: path.resolve(__dirname, 'node_modules/sonderborg-calendar/player.js'),
},
},
Configuration
config/sonderborg_calendar.php:
return [
'default_width' => 1024,
'default_height' => 720,
'autoplay' => false,
];
{{ render(sonderborg_calendar_template, {
'width': app.config.get('sonderborg_calendar.default_width')
}) }}
Event Listeners
use Bibsdb\SonderborgCalendarBundle\Event\VideoLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class SonderborgSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
VideoLoadedEvent::class => 'onVideoLoaded',
];
}
public function onVideoLoaded(VideoLoadedEvent $event)
{
// Log or track video views
\Log::info('Video loaded', ['url' => $event->getUrl()]);
}
}
Ads/Controls Not Disabled
Template Not Loading
bibsdb:core:templates:load fails silently.storage/logs/laravel.log for errors.vendor/bibsdb/sonderborg-calendar-bundle/Resources/views/.-v for verbose output:
php artisan bibsdb:core:templates:load -v
JavaScript Conflicts
$ or jQuery conflicts.DOMContentLoaded event or use Laravel’s @stack:
@stack('scripts')
@push('scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
SonderborgPlayer.init({{ json_encode($config) }});
});
</script>
@endpush
CORS Errors
Check the Network Tab
F12) and verify the player’s JavaScript/CSS loads without 404s.Uncaught ReferenceError: SonderborgPlayer is not defined).Log Configuration
\Log::info('Sonderborg Config:', [
'width' => config('sonderborg_calendar.default_width'),
]);
Fallback for Missing JS
{% if sonderborg_player_loaded %}
{{ render(sonderborg_calendar_template, { ... }) }}
{% else %}
<div class="fallback">
<p>Player failed to load. <a href="{{ video_url }}">Download video</a>.</p>
</div>
{% endif %}
Custom Player Styling
php artisan vendor:publish --tag=sonderborg-calendar-assets
resources/css/sonderborg-player.css and recompile assets.Add Analytics
init function via a custom JavaScript file:
// resources/js/sonderborg-extended.js
window.SonderborgPlayer = window.SonderborgPlayer || {};
SonderborgPlayer.init = function(config) {
// Original logic
this.player.init(config);
// Custom analytics
if (config.trackingId) {
this.player.on('play', function() {
_paq.push(['trackEvent', 'Video', 'Play', config.videoUrl]);
});
}
};
Support Multiple Players
namespace App\Services;
use Bibsdb\SonderborgCalendarBundle\Player;
class SonderborgManager
How can I help you explore Laravel packages today?