Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Render Widget Laravel Package

victoire/render-widget

A Laravel package for rendering reusable widgets from PHP classes and Blade views, helping organize view logic and compose clean, maintainable UI blocks across your application.

View on GitHub
Deep Wiki
Context7

Getting Started

Treat this as a legacy Symfony bundle first, not a greenfield dependency. Before installing, check composer.json in the repository for PHP and Symfony version constraints; the last release was April 2019, so expect Symfony 3.x/4.x-era code rather than Symfony 6/7 compatibility.

Minimal setup:

composer require victoire/render-widget

Enable the bundle using the convention for your Symfony version. For Symfony 3:

// app/AppKernel.php
$bundles[] = new Victoire\WidgetRenderBundle\VictoireWidgetRenderBundle();

For Symfony 4+ Flex-style apps:

// config/bundles.php
return [
    // ...
    Victoire\WidgetRenderBundle\VictoireWidgetRenderBundle::class => ['all' => true],
];

Confirm the actual bundle class name from the repository’s bundle class and composer.json; old Victoire bundles sometimes use non-obvious namespaces.

Where to look first:

  1. README.md for the supported Twig function or service name.
  2. Resources/config/services.* for the renderer service ID and aliases.
  3. The Twig extension class for the exact function signature.
  4. Any controller or compiler pass that registers widget rendering.

First practical use case: render a widget from a Twig template instead of hardcoding its controller/template. In a Victoire-style page layout that usually looks like:

{# Confirm the exact function name/signature from the installed Twig extension. #}
{{ render_widget(widget) }}

If the package exposes an ID-based API instead, it may look like:

{{ render_widget(widget.id) }}

Start by rendering one known widget in a simple template, then wire it into the page/template layout only after the output and cache behavior are understood.

Implementation Patterns

Twig-first rendering. The main day-to-day use is likely a Twig function that takes a widget object or identifier and returns rendered markup. Keep widget rendering in templates where editors expect it, and keep controllers thin.

Controller/service rendering for non-Twig contexts. For emails, JSON APIs, PDFs, or CLI-generated pages, inject the renderer service directly rather than calling Twig. Find the service ID with:

bin/console debug:container render
bin/console debug:container --tag=twig.extension

Then wrap it in your own application service:

final class WidgetPresenter
{
    public function __construct(private $widgetRenderer) {}

    public function present(Widget $widget): string
    {
        return $this->widgetRenderer->render($widget);
    }
}

Page-layout integration. In a CMS page template, iterate the page’s widget map and render each widget through the bundle:

{% for widget in page.widgets %}
    <section class="widget widget--{{ widget.type }}">
        {{ render_widget(widget) }}
    </section>
{% endfor %}

This keeps widget-specific templates inside the widget package and avoids a giant switch in the page template.

Cache per widget. Widget rendering is a natural fragment boundary. Use Symfony fragment caching or ESI where possible:

{{ render_esi(controller('App\\Controller\\WidgetController::show', {id: widget.id})) }}

If you use the bundle’s Twig function directly, add your own cache key around it and include the widget’s updatedAt value so editor changes invalidate output.

AJAX/dynamic widgets. For widgets that change after page load, render a shell in Twig and fetch the widget endpoint from JavaScript. Keep the endpoint authenticated/authorized the same way as the page; do not rely on the widget ID being unguessable.

Testing pattern. Create a fixture widget, render it through the bundle in a kernel/functional test, and assert the expected markup. This catches template-resolution and service-wiring failures early, which matters more here because the package has little community usage.

Gotchas and Tips

  • Legacy risk is the main gotcha. Three stars, zero dependents, and a 2019 release mean this is effectively unmaintained for modern Symfony. Pin the exact version in composer.json, and be prepared to fork or vendor the bundle.
  • Symfony compatibility will fail before your code does. Old bundles often rely on deprecated service visibility, bundle inheritance, or container APIs removed in Symfony 5/6. Run composer why-not symfony/framework-bundle and check the bundle class before debugging templates.
  • Confirm the Twig function before using examples. The exact name may be render_widget, widget_render, or a service call. Inspect the Twig extension class; do not assume from the package name.
  • Bundle registration order can matter. If this bundle depends on Victoire core/widget services, register it after those bundles. Missing service definitions usually show up as “service not found” during container compilation.
  • Template namespaces are easy to miss. Old bundles often use @VictoireWidgetRender/... paths. Use bin/console debug:twig to list namespaces and bin/console lint:twig templates to catch bad references.
  • Avoid passing detached entities into the renderer. Render widgets inside the request/entity-manager scope. If you queue rendering or serialize widgets, pass IDs and reload them in the renderer.
  • Cache invalidation is manual. If you cache widget output, include the widget ID, locale, user/role context if relevant, and updatedAt. Otherwise editors will change a widget and see stale output.
  • Escape deliberately. Widget templates may output editor-supplied HTML. Treat raw HTML as trusted only after your own sanitization; do not disable Twig escaping globally to make a widget work.
  • Debug with container and Twig commands first. bin/console debug:container, debug:twig, and lint:twig will usually locate wiring/template issues faster than reading the bundle source.
  • Extension points are likely service decoration and template overrides. Prefer decorating the renderer service or overriding a widget template over editing vendor code. Keep a local fork only if the bundle is abandoned and you need Symfony compatibility fixes.
  • Do not build new architecture around it. For new projects, implement a small widget renderer yourself or use a maintained CMS/component system. Use this package only when maintaining an existing Victoire installation or when its widget model is already a hard requirement.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels