yepsua/smartwig-bundle
Symfony bundle that integrates Smartwig's Twig extensions, letting you build rich UI widgets—grids, dialogs, and jQuery UI components—directly in your templates with minimal PHP. A lightweight way to add reusable, template-driven interface elements to Symfony apps.
The first thing to understand is that this is a Symfony2 bundle, not a Laravel package — so "day-to-day leverage" for a Laravel developer mostly means one of two things: (a) you're maintaining a legacy Symfony2 app that already depends on it, or (b) you're using it as a reference for how to wrap jQuery UI widget generation into server-side templates. There is no Blade/Laravel service provider here.
If you're on a Symfony2 app:
composer.json in the repo first — it targets Symfony ~2.1+ and jQuery4PHP. Do not attempt to install on Symfony 4+/Laravel; the Yepsua\SmarTwigBundle\YepsuaSmarTwigBundle class uses the old bundle conventions and Twig APIs.composer require yepsua/smartwig-bundleapp/AppKernel.php:
new Yepsua\SmarTwigBundle\YepsuaSmarTwigBundle(),
php app/console assets:install --symlink web/First use case — a jQuery UI dialog:
{% ui_dialog title="Hello" autoOpen=true %}
<p>This content is rendered server-side and handed to jQuery UI.</p>
{% end_ui_dialog %}
The bundle's Twig extensions translate tag + attributes into jQuery4PHP component objects, which render as inline <script> calls during template output. Look first at Resources/config/ for the service definitions and Twig/ for the tag extensions — that is where the actual attribute-to-option mapping lives, and it is your source of truth when documentation is thin (which it is).
1. Declarative widgets via Twig tags. Each supported widget has a matching tag (ui_dialog, ui_button, ui_tabs, ui_accordion, ui_datepicker, ui_slider, ui_progressbar, ui_autocomplete, jqgrid, etc.). Attributes on the tag map to jQuery4PHP/jQuery UI options. Nest tags to compose layouts (tabs containing grids, dialogs containing forms).
2. jQuery4PHP as a programmatic layer. The underlying jQuery4PHP library can be used outside Twig — in a controller or a small service — by building component objects and calling ->render() (or ->execute()) to emit the script. This is useful when a widget's configuration is driven by runtime data (column models for jqGrid, dynamic tab lists, etc.) that would be awkward as literal tag attributes.
3. Ajax data patterns. The most practical real-world use is jqGrid + a Symfony controller that returns JSON. Keep the data endpoint a normal controller returning new JsonResponse(...) (or Response with application/json), and let the grid tag point at the route. Keep pagination/sorting params (page, rows, sidx, sord) handled server-side.
4. Assetic for asset wiring. Since this predates Symfony Webpack Encore, you'll be combining it with Assetic to bundle jQuery, jQuery UI themes, and plugin assets. Define combined files in config.yml and reference them in the layout.
5. Forms + widgets. Pair Symfony form rendering with jQuery UI widgets — render the field normally, then attach a ui_datepicker/ui_autocomplete tag targeting the input's selector. Avoid rebuilding the form in JS; let the server own field names and CSRF tokens.
6. Extending with custom widgets. The extension point is a Twig extension that instantiates a jQuery4PHP component and returns its script. Register it as a tagged Twig extension service. This is the sanctioned way to add a widget the bundle doesn't ship.
7. Porting the pattern to Laravel. If your actual goal is a Laravel app, the reusable idea is: a Blade component/directive that owns the JS for one widget, driven by an options array, emitting a data-* payload that a small JS initializer consumes. That gets you the same declarative ergonomics without the dead dependency.
$.browser, some jQuery UI widget signatures) that jQuery4PHP-generated code may rely on. Pin jQuery and jQuery UI versions if you must run it.assets:install (or the newer equivalent) is the classic "nothing renders" failure — the widget JS exists in the bundle but not in web/.<script> blocks. If your tag output appears before jQuery is loaded, you get $ is not defined. Ensure the widget region renders after the library scripts — usually by placing widgets in the body, not the head, and by depending on the bundle's document-ready hook rather than raw inline calls.{%-), and attribute quoting can trip the token parser. When a tag silently fails, simplify to a single flat widget first, then re-nest.<p> tags, that's the culprit.Resources/views/ before forking — and be aware that bundle-level overrides are fragile across Symfony minor bumps.config.yml. Don't waste time hunting for a knob that isn't there — read the extension class.How can I help you explore Laravel packages today?