Simple and easy to install Symfony 2 bundle for the implementation of Twitter Bootstrap.
-
Include repository in your
deps
file:[lessphp] git=git://github.com/leafo/lessphp.git target=/lessphp version=v0.3.4-2 [twitter-bootstrap] git=git://github.com/twitter/bootstrap.git target=/twitter/bootstrap version=v2.0.3 [TwitterBootstrapBundle] git=git://github.com/isdev/Twitter-Bootstrap-bundle.git target=/bundles/Isdev/TwitterBootstrapBundle version=origin/master-lessphp
And run the
vendors
script to download the bundle:$ php bin/vendors install
-
Copy file
variables.less
in folderapp/Resources/styles/twitter
:$ mkdir -p app/Resources/styles/twitter $ cp vendor/twitter/bootstrap/less/variables.less app/Resources/styles/twitter/variables.less
And set variables values in
app/Resources/styles/twitter/variables.less
:@iconSpritePath: "../../../../../../twitter/bootstrap/img/glyphicons-halflings.png"; @iconWhiteSpritePath: "../../../../../../twitter/bootstrap/img/glyphicons-halflings-white.png";
-
Add namespace to your
app/autoload.php
file:<?php // ... $loader->registerNamespaces(array( // ... 'Isdev' => __DIR__.'/../vendor/bundles', ));
-
Register bundle in
app/AppKernel.php
file:<?php // ... public function registerBundles() { $bundles = array( // ... new Isdev\TwitterBootstrapBundle\IsdevTwitterBootstrapBundle(), ); // ... return $bundles; }
-
Register assetic filter to compile LESS in the CSS in
app/config/config.yml
file:assetic: # ... filters: # ... lessphp: file: "%kernel.root_dir%/../vendor/lessphp/lessc.inc.php"
-
Register twig form template for whole project in
app/config/config.yml
file:twig: # ... form: resources: - "IsdevTwitterBootstrapBundle:Form:fields.html.twig"
Or include the
fields.html.twig
in your template for a special form:{% form_theme special_form 'IsdevTwitterBootstrapBundle:Form:fields.html.twig' %}
-
Bundle includes the basic template. For a quick start you can just inherit from it your template:
{% extends 'IsdevTwitterBootstrapBundle::base.html.twig' %}
- refine form template