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

Bootstrap Bundle Laravel Package

digineers/bootstrap-bundle

BraincraftedBootstrapBundle integrates Bootstrap into Symfony2 projects, with support for the official Sass port of Bootstrap and Font Awesome. Install it via Composer, register the bundle, and configure Assetic to compile the LESS files.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the bundle with Composer ("braincrafted/bootstrap-bundle": "~2.2" — pin explicitly, dev-master moves), then register it in app/AppKernel.php:

new Braincrafted\Bundle\BootstrapBundle\BraincraftedBootstrapBundle(),

Before touching templates, check the compatibility matrix in the README. Version 2.2.x maps to Symfony 2.3–3.0 and Bootstrap 3.0–3.2 only. If your project is on Symfony 4+/Flex, stop here — this bundle will not boot.

Next, look at the documented Getting Started page rather than the README, because the README stops at registration. The practical sequence is:

  1. app/console braincrafted:bootstrap:install — pulls jQuery and Bootstrap into web/ (versions configurable; web-dir is configurable since 2.1 beta2).
  2. app/console braincrafted:bootstrap:generate — writes a bootstrap.less/bootstrap.scss entry file with @import statements and variables you can then override.
  3. Wire Assetic (or your own build) to compile that file and dump it to web/css.
  4. Enable the form theme — the single most valuable thing the bundle gives you:
# config.yml
twig:
    form_themes:
        - 'BraincraftedBootstrapBundle::form.html.twig'

(On Symfony < 2.6 this is the form.resources key instead — see gotchas.)

Your first real use case: take an existing Symfony form, apply bootstrap_3_horizontal_layout.html.twig, and every form_row starts emitting form-group, control-label, form-control and error has-error classes without a single template change. That alone justifies the dependency on a Bootstrap 3 project.

Implementation Patterns

Form theming at three scopes. Global via twig.form_themes, per-template via {% form_theme form 'bootstrap_3_layout.html.twig' %} (note the short name works because the bundle ships well-known theme paths), or per-form-type via setDefaultOptions(['inherit_data' => ...]) plus a theme. Prefer per-template when only one page is Bootstrap-styled; the global config leaks Bootstrap markup into emails and PDFs if you reuse form rendering there.

Horizontal layouts are option-driven. label_col_size and widget_col_size (plus col_size for the wrapper) are read by the horizontal theme. Set them once on the form type's buildForm/configureOptions rather than per field, and override per field only when a widget genuinely differs (e.g. a file upload that needs col-md-10).

Collections with add/remove rows. Swap CollectionType for BootstrapCollectionType and include bc-bootstrap-collection.js. The template contract is the standard Symfony data-prototype attribute plus data attributes the JS reads (data-prototype-name, data-prototype-label). The JS fires bc-collection-add / bc-collection-remove events on the container, so bind your own recalculations (index numbering, price totals, select2 re-init) there instead of patching the script.

{{ form_row(form.items, { attr: { 'data-prototype': prototype } }) }}

Static/read-only values. Use the shipped static control form type instead of rendering {{ value }} manually — it keeps the row structure and label alignment consistent with editable siblings.

Flash messages. The FlashMessageFactory service (braincrafted_bootstrap.flash) turns $session->getFlashBag()->add('success', ...) into styled, dismissible alert divs; danger() exists for error-level messages. Render them once in layout.html.twig via the flash_alert filter rather than repeating markup in controllers' templates.

Icons and buttons are Twig-level sugar. {{ icon('pencil') }}, {{ parse_icons(label) }}, {{ button('Save', 'primary', 'save') }}, {{ button_link(url, 'Cancel') }}. These are worth using in menus and collection rows where the same <span class="glyphicon"> boilerplate would otherwise repeat dozens of times. parse_icons only works inside the bundle's own helpers (button, button_link, badge, label), not arbitrary strings.

Assetic integration. The bundle ships LESS/SCSS filters config. Apply them to the generated bootstrap.less, and keep your own application styles in a separate file so a Bootstrap version bump doesn't force a rewrite. In dev enable assetic.use_controller; in prod dump to web/ during deploy. If you already have gulp/Encore/mix, skip this layer entirely — the bundle's Twig and form parts work fine without Assetic.

Gotchas and Tips

The Symfony 2.6 rename bites everyone. form.resources became form_themes. If forms silently render without Bootstrap classes, you are on the wrong key for your Symfony version — the bundle's changelog explicitly notes the switch.

This package is effectively end-of-life. Last release 2016, Symfony 3.0 ceiling, no Symfony 4/5/6 support, Twig 1.x APIs baked into extensions. Any new project should treat it as a historical reference and hand-roll the form theme (bootstrap_4_*/bootstrap_5_* themes now ship with Symfony core) or use a maintained alternative. Keep it only in brownfield Symfony 2 projects you cannot upgrade.

Do not assume the install command is idempotent. It downloads assets into web/ and will happily clobber customized copies. Back up web/js/web/css before rerunning, or use the configurable web-dir to point at a staging folder and copy deliberately.

Sass support has an external dependency. The SCSS path needs either a sass binary or leafo/scssphp; without it Assetic fails at dump time with an unhelpful filter-not-found error. Check assetic.filters registration and clear app/cache after changing it — Assetic caches compiled output aggressively.

Collection JS is jQuery- and Bootstrap-3-specific. bc-bootstrap-collection.js relies on .size() historically (fixed late, but old copies still have it) and on Bootstrap 3 tooltip/popover semantics. If you upgraded anywhere, vendor the file and patch rather than tracking the bundle.

label => false has known layout quirks in horizontal forms — column offsets get miscomputed. Workaround: set a zero-width label column (label_col_size = 0) rather than disabling the label outright.

File inputs never render a value by design (security), so don't add a "current file" display expecting the widget to do it — render it yourself alongside the field.

Extension points if you must fork behavior: override the bundle's templates using standard bundle template overriding (app/Resources/BraincraftedBootstrapBundle/views/Form/...), and extend BootstrapCollectionType if you need custom prototype names. There is no event-driven extension API for the form theme itself, so template overrides are the only clean seam.

Debug checklist when styling disappears: (1) form theme actually registered, (2) correct key for your Symfony version, (3) bootstrap.css actually compiled and linked — view source, don't trust the layout, (4) cache cleared after config edits. In that order; the third is the most common false alarm.

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.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons