bibsdb/portrait-portrait-bundle
Installation
Add the repository to composer.json under "repositories":
"repositories": {
"bibsdb/portrait-portrait-bundle": {
"type": "vcs",
"url": "https://github.com/bibsdb/portrait-portrait-bundle"
}
}
Require the bundle:
composer require bibsdb/portrait-portrait-bundle
Enable the Bundle
Register the bundle in config/bundles.php (Laravel 5.4+) or AppKernel.php (older versions):
Bibsdb\PortraitPortraitBundle\BibsdbPortraitPortraitBundle::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 your admin panel (e.g., SonataAdmin, EasyAdmin) and enable the Portrait-Portrait template.
To embed a Portrait-Portrait video in a slide:
Get a User Token Ensure the video URL comes from a PLUS account (or a user who disabled ads/controls) via portrait-portrait.com.
Use the Template in a Slide In your slide configuration (e.g., via admin UI or API), select the Portrait-Portrait template and input the video URL:
# Example slide config (YAML/JSON)
template: portrait_portrait
video_url: "https://portrait-portrait.com/embed/your-video-id"
Render the Slide The bundle will automatically inject the player.js script and render the video player.
Extend Slide Entities
If using a custom slide entity (e.g., Slide), add fields for Portrait-Portrait-specific data:
// Example migration
Schema::table('slides', function (Blueprint $table) {
$table->string('portrait_portrait_video_url')->nullable();
});
Template Overrides Override the default template by publishing assets:
php artisan vendor:publish --tag=portrait-portrait.templates
Modify resources/views/portrait_portrait/slide.html.twig to customize the player appearance.
Dynamic Video Loading
Fetch videos dynamically via API (e.g., from a Video model):
{# In your slide template #}
<div class="portrait-portrait-player"
data-video-url="{{ slide.portrait_portrait_video_url }}">
</div>
Asset Management
Ensure player.js and CSS are loaded via the bundle’s asset pipeline. Check resources/views/portrait_portrait/layout.html.twig for dependencies.
Admin Panel Integration For SonataAdmin/EasyAdmin, create a custom form type to handle the video URL:
use Symfony\Component\Form\Extension\Core\Type\UrlType;
$builder->add('portraitPortraitVideoUrl', UrlType::class, [
'required' => false,
'label' => 'Portrait-Portrait Video URL',
]);
Lazy Loading
Use the data-src attribute for deferred loading:
<div class="portrait-portrait-player"
data-src="{{ slide.portrait_portrait_video_url }}">
</div>
Ads/Controls Not Disabled
Template Not Loading
php artisan bibsdb:core:templates:load.var/cache/ for template files.CORS Errors
portrait-portrait.com or use a proxy.Check Console Logs Inspect browser console for errors like:
// Expected: player.js should load without 404s.
Uncaught Error: Cannot find module 'player.js'
Verify Template Selection
Ensure the admin panel is configured to select the Portrait-Portrait template. Check the database for the correct template field value.
Custom Player Options Extend the player configuration via Twig:
<div class="portrait-portrait-player"
data-video-url="{{ slide.video_url }}"
data-autoplay="true"
data-mute="true">
</div>
Refer to player.js docs for supported options.
Event Listeners Hook into slide events to preprocess Portrait-Portrait URLs:
// Example: In a service provider
$this->app->booted(function () {
event(new SlideEvent('portrait_portrait', $slide));
});
Fallback for Unsupported Browsers Add a polyfill or fallback UI in your template:
{% if is_grumphp_browser_supported %}
{{ include('portrait_portrait/player.html.twig') }}
{% else %}
<div class="fallback-message">
Your browser does not support Portrait-Portrait videos.
</div>
{% endif %}
How can I help you explore Laravel packages today?