Integrating Twitter Bootstrap 3.2 into Symfony 2.3 Project

I have tried integrating Twitter Bootstrap 3.2 into a Symfony 2.3 project.

Just found Tutorials for Bootstrap 3.0 with leafo / lessphp but this is no longer supported and furthermore it doesn't work for Bootstrap 3.2. I haven't found anything like leafo / lessphp which supports the latest Bootstrap.

Is there a way to integrate Bootstrap 3.2 into a Symfony 2.3 project?

Hello

+3


source to share


4 answers


It depends on what you mean by integration: if you only mean CSS and JS files, just upload them, include them in your assets folder and require templates from them.



If you want control over the way the LESS / SASSS source is generated, you might be interested in this bundle [which made it magically appear as the first result after googling for "symfony bootstrap"].

+2


source


symfony 2.6 Easy installation and update via composer. This is only for fonts, css, js.

composer.json

"require": {
    "twbs/bootstrap": "~3.3"
}

"post-install-cmd": [
   "php -r \"if (!file_exists('web/bundles/bootstrap/')){  symlink(__DIR__.'/vendor/twbs/bootstrap/dist', 'web/bundles/bootstrap');}\""
    ]
"post-update-cmd": [
   "php -r \"if (!file_exists('web/bundles/bootstrap/')){  symlink(__DIR__.'/vendor/twbs/bootstrap/dist', 'web/bundles/bootstrap');}\""
    ]

      

base.html.twig



<link href="{{ asset('bundles/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet"/>
<script src="{{ asset('bundles/bootstrap/js/bootstrap.min.js') }}"></script>

      

Then run the command in the root directory

composer update twbs/*

      

+5


source


You have to include CSS and JS files in your twig file like this:

<link rel="stylesheet" href="{{asset('bundles/bundleName/css/bootstrap.css')}}">
<script src="{{ asset('bundles/bundleName/js/bootstrap.min.js') }}" ></script>

      

+2


source


Sorry for being unclear. I am using composer and config.yml to upload files.

I also looked at node yesterday (first result), but there was an easy way to set it up for bootstrap 3.0, so I asked myself if there was an easy way to do this with bootstrap 3.2.

I don't want to include js and css files manually, I want composer / Symfony to do it.

This was the case with bootstrap 3.0:

http://mossco.co.uk/symfony-2/symfony-2-and-bootstrap-3-assetic-config-and-base-html-template-file/

The less the more it is not supported / developed, it does not work for 3.2 bootstrap.

Hopefully the question is clear enough now. If you have any approach without a kit, you can really help me.

If this is the easiest and most reliable way: https://github.com/braincrafted/bootstrap-bundle I will use this bundle.

0


source







All Articles