My goal is to use the Bootstrap Glyphicons font in my Symfony (2.8) web application. I am using assetic but it is there that I have my problem. I added bootstrap in my composer.json file ("twitter/bootstrap": "3.3."). After running composer install, I checked the path in the original bootstrap.css file (vendor folder) and the url to the fonts look as follows (which is okay of course, as the fonts can be found there): "src: url('../fonts/glyphicons-halflings-regular.eot');".
However, when checking the result in the web/css folder after running assetic:dump, I see that the path is wrongly changed to "src: url('../../fonts/glyphicons-halflings-regular.eot');" (notice the "../" that was added)
The assetic part in my config.yml file looks like as follows:
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ 'AppBundle' ]
filters:
cssrewrite: ~
assets:
bootstrap_js_and_jquery:
inputs:
- '%kernel.root_dir%/../vendor/components/jquery/jquery.js'
- '%kernel.root_dir%/../vendor/twbs/bootstrap/dist/js/bootstrap.js'
bootstrap_css:
inputs:
- '%kernel.root_dir%/../vendor/twbs/bootstrap/dist/css/bootstrap.css'
bootstrap_glyphicons_ttf:
inputs:
- '%kernel.root_dir%/../vendor/twbs/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf'
output: "fonts/glyphicons-halflings-regular.ttf"
bootstrap_glyphicons_eot:
inputs:
- '%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.eot'
output: "fonts/glyphicons-halflings-regular.eot"
bootstrap_glyphicons_svg:
inputs:
- '%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.svg'
output: "fonts/glyphicons-halflings-regular.svg"
bootstrap_glyphicons_woff:
inputs:
- '%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.woff'
output: "fonts/glyphicons-halflings-regular.woff"
bootstrap_glyphicons_woff2:
inputs:
- '%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.woff2'
output: "fonts/glyphicons-halflings-regular.woff2"
The result of this is that the css files can be found in 'web/css' and the fonts in 'web/fonts' (so all of that looks fine).
In my twig template I applied the cssrewrite rule:
{% stylesheets '@bootstrap_css' filter='cssrewrite'%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
Can anyone explain me why the path in the css file is rewritten by adding "../" in front of the path, which makes that the fonts cannot be found (404)? Did anyone managed to get this working in a similar set-up?
Thanks in advance.