Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 and Twitter Bootstrap

Tags:

I just came across Twitter Bootstrap today, on SO. I have skimmed through some online tutorials and if my understanding so far is correct, using the TB essentially consists of:

  1. Downloading TB, extracting CSS files etc
  2. Referencing the required CSS, JS files in your HTML doc and using the defined CSS patterns

I want to use Twitter Bootstrap with Symfony2. Given my understanding of how to use TB I thought it would be relatively easy to use it with Symfony, so I was quite suprised to see that there are (actually several) Bundles to use with Symfony.

So my questions are:

  1. Why is a Bundle needed to use Twitter Bootstrap with Symfony2? - will the method I explained above not work (i.e. adding the references directly in a twig template)?

  2. Since there are several Twitter Bootstrap Bundles available (at last count there are 3), which is the easiest to use (it has to be one that is actively supported with recent commits, and not a dead project)

like image 317
Homunculus Reticulli Avatar asked Aug 14 '12 13:08

Homunculus Reticulli


People also ask

Is twitter made with Bootstrap?

Bootstrap, originally named Twitter Blueprint, was developed by Mark Otto and Jacob Thornton at Twitter as a framework to encourage consistency across internal tools.

What kind of framework is twitter bootstrap?

Twitter Bootstrap is an open source front end framework for HTML, CSS and JS, using which we can create a responsive UI for our web application. This is supported by all major browsers.

Is twitter bootstrap responsive?

With Bootstrap 2, we've gone fully responsive. Our components are scaled according to a range of resolutions and devices to provide a consistent experience, no matter what.

Why is it called twitter bootstrap?

Bootstrap is referred to as Twitter Bootstrap because it was developed by two employees Mark Otto and Jacob Thornton at Twitter. It was originally called Twitter Blueprint before it was released as an open-source project on Github in August of 2011.


2 Answers

I'm pretty sure these Bundles are great, but they have advantages and drawbacks. You could also use TB without a Bundle directly in your project. That's what I personally do, that way:

  • git clone TB in web/ (to get latest updates and keep updated)
  • I directly call bootstrap.less in my twig templates with Assetic and the less filter. That way, I can create my own .less files that @imports TB and use their astonishing mixins for example.

It's really powerful this way. Coupled with yui-compressor, when I use Assetic in no-debug mode, all my js and less files are compiled into one single .css output and one single .js output. And you could benefit from all TB functionalities, in .less, not .css

like image 168
guillaumepotier Avatar answered Sep 20 '22 03:09

guillaumepotier


There are 2 major bundles that provides symfony integration with Twitter Bootstrap:

  • MopaBootstrapBundle
  • BcBootstrapBundle

In my opinion:

MopaBootstrapBundle is more complex, provides its own layout structure (of cause you can create your own too) and lot of defined functionality, extra assetic, forms and other integration

BcBootstrapBundle is more simple and much more clear you use your own layout structure and there is a lot of defined functionality, extra assetic, forms and other integration too

dont use any intergtaion bundle also is an option, but you loose integration with forms, assetic, less and so (as @Acyra mentioned in his comment)

I prefer to use BcBootstrapBundle with its extra integration functionality and use my own custom layout structure.

like image 31
pleerock Avatar answered Sep 20 '22 03:09

pleerock