jbsnewmedia/bootstrap-bundle
jbsnewmedia/bootstrap-bundle integrates Bootstrap into Symfony applications, providing ready-to-use form themes, Twig helpers, and asset handling. It streamlines setup and customization so you can build consistent, responsive interfaces faster while keeping templates clean and maintainable.
This is a Symfony bundle (works fine in Laravel-adjacent PHP stacks only insofar as you can shell out to its commands — there is no Laravel service provider here). It wraps the Bootstrap toolchain: scaffolding, SCSS compilation, and CSS purging via three console commands.
Minimal setup:
composer require jbsnewmedia/bootstrap-bundle (requires PHP 8.2+ and Symfony 7.4 components — check your app's PHP/Symfony constraint before pulling this into an older project).config/bundles.php (Symfony) or add the console commands to your runner if you're wiring it manually.config/packages/ — this is where SCSS entry points, output directories, and purge targets are declared. The README (now with a full German translation and expanded troubleshooting) is the fastest path to the correct key names.bootstrap:init to scaffold the expected directory structure and starter SCSS. This is your first use case: it creates the files the other two commands assume exist, so run it before anything else.The typical first win: point the config at your existing assets/scss/app.scss, run bootstrap:compile, and confirm you get compiled CSS in the configured output dir. Only then introduce bootstrap:purge.
Compile-on-demand in dev, purge-on-build in CI. Wire bootstrap:compile into your local watcher or a Composer script so SCSS changes are picked up without a full asset rebuild. Keep bootstrap:purge out of the dev loop — purging against a dev page set produces misleading results because your local browsing rarely hits every template.
Purge against rendered output, not source. The reliable pattern is: build the app, render the routes/templates you care about (a crawler, a snapshot test, or a static export), then run bootstrap:purge pointed at that HTML. Purge tools work on class names found in markup; scanning Twig/Blade source directly will miss dynamically composed class strings and over-purge.
Chain the commands in a build step. A single CI job running bootstrap:compile → render → bootstrap:purge gives you a deterministic, cacheable artifact. Make the output directory a build artifact rather than a committed file, and let the pipeline own regeneration.
Override Bootstrap variables before compiling. The idiomatic use of an SCSS-based bundle is a custom _variables.scss imported ahead of Bootstrap's own partials. Do this instead of post-processing the compiled CSS — it's the whole reason to compile SCSS rather than ship a CDN link.
Config as the single source of truth. Paths, purge safelists, and output filenames belong in the bundle config, not baked into scripts. Since 1.0.5 refactored compilation and purging into dedicated factory classes with better error reporting, config mistakes now surface as clear console errors instead of silent empty output — lean on that and keep config declarative.
Safelist deliberately. Any class assembled at runtime (btn-{{ $variant }}, JS-toggled classes, classes only present after an AJAX response) needs an explicit safelist entry. Treat the safelist as documentation of your dynamic class surface.
bootstrap:init before compile or purge. The 1.0.5 error handling now fails earlier and more clearly when expected files are missing, which is an improvement — but it also means a fresh checkout without the scaffolded structure will hard-fail where it might previously have limped along.-vvv; the improved messages are designed to tell you which path or dependency failed.How can I help you explore Laravel packages today?