What is the correct way to add bootstrap to a symfony app? What is the correct way to add bootstrap to a symfony app? symfony symfony

What is the correct way to add bootstrap to a symfony app?


It looks like that this no longer works in Symfony3.

In Symfony3 the following should work:

twig:    form_themes: ['bootstrap_3_layout.html.twig']


The Symfony Best Practies gives the answer for this Problem: https://symfony.com/doc/current/best_practices.html#web-assets

If you are developing an application like this, you should use the tools that are recommended by the technology, such as Bower and GruntJS. You should develop your frontend application separately from your Symfony backend (even separating the repositories if you want).

In our project we use grunt to build and concat those files into the web-folder.


The suggested approach changed since Symfony version 4: Webpack Encore is used with npm / yarn for bundling the CSS and JavaScript resources, where the Bootstrap framework can be included.

Start by installing Encore and follow with the Bootstrap-specific documentation. In summary, the following commands have to be performed:

composer require symfony/webpack-encore-bundleyarn installyarn add bootstrap --dev# after making the required changes to webpack.config.js, app.js, run Encoreyarn encore dev --watch