Rewrite CSS URLs to a public directory with Assetic

A new bundle is available in Symfony2 ecosystem: AlexAsseticExtraBundle. This bundle provides a new Assetic filter: Asset Directory : this filter copy all your images and fonts of your CSS files to web/assets.

If your CSS files are located in vendor/ folder and reference images not accessible to the web/ folder, this filter is for you!

Twitter Bootstrap as a vendor

When you are using a vendor code, it is not a good practice to version it. Using PHP and Packagist, you can add Twitter Bootstrap as a dependency in your composer.json:

{
    "twitter/bootstrap": "~3.0",
}

Install AlexAsseticExtraBundle according to Github instructions

And in your template:

{% stylesheets filters="combine,assetdirectory"
    "../vendor/twitter/bootstrap/dist/css/bootstrap.css"
%}
    {# ... #}
{% endstylsheets %}

This filter will compile Twitter Bootstrap using Assetic filters and copy assets (icon fonts) to an assets/ folder in your public directory.

Details

Get more informations on Github repository