3

I tried to integrate Twitter Bootstrap 3.2 on my Symfony 2.3 project.

Just found Tutorials for Bootstrap 3.0 with leafo/lessphp , but this is not supported anymore and in addition it is not working for Bootstrap 3.2 . I found nothing similar to leafo/lessphp that supports the latest Bootstrap version.

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

Regards

2
  • Add a reference to the css/js, update the html structure - and poof it is integrated. What is the issue? Commented Sep 3, 2014 at 10:09
  • i posted a comment below as there were a few answers like yours. Was my fault that i posted the question not clear enough. Regards Commented Sep 3, 2014 at 11:26

4 Answers 4

4

symfony 2.6 Simple install and update via composer. It is just 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 command in web root

composer update twbs/*
Sign up to request clarification or add additional context in comments.

1 Comment

That was handy. For portability reasons, I prefer the symlink to be relative though, and not use the absolute path on the developers machine... "php -r \"if (!file_exists('web/bundles/bootstrap/')){ symlink('../../vendor/twbs/bootstrap/dist', 'web/bundles/bootstrap');}\""
2

It depends from what do you mean by integrating: if you mean just including the CSS and JS files, just download them,include them in your assets folder and require them from you templates.

If you want to have control over the way the LESS/SASSS source is generated, you may be interested on this bundle [which did magically show up as the first result after googling for "symfony bootstrap"].

3 Comments

BraincraftedBootstrapBundle also provides bootstrap form rendering and menu rendering with KnpMenuBundle :)
Do i have to install there a LESS and a SASS compiler or is it enough to just install the LESS or SASS ? It is not clearly enough mentioned in their documentation. Which one should i choose than?
In their docs, they say to rely on Assetic.
2

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

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

Comments

0

Sorry for being unclear. I'm using composer and config.yml to load the files.

I also took a look yesterday at the bundle (first result), but for bootstrap 3.0 there was an easy way to configure, so i asked myself if there was also an easy way to do it with bootstrap 3.2.

I don't want to include the js and css files manually, want to let this be done by composer / Symfony.

This was the way it worked with bootstrap 3.0:

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

As the less is not supported / developed anymore, it doesnt work for 3.2 bootstrap.

Hope the question is now clearly enough. If theres any approach without the bundle you'd really help me.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.